Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


iRedMail (OpenLDAP) restore from LDIF

  • Stop slapd:
    systemctl stop slapd
  • Check LDAP directory and delete files in directory below, except DB_CONFIG:
    # find openldap directory
    grep ^directory /etc/openldap/slapd.conf
    directory   /var/lib/ldap/<yourdomain>
    # delete files from directory
    cd /var/lib/ldap/<yourdomain>
    shopt -s extglob
    rm -f !(DB_CONFIG)
  • Start and immediately stop slapd to recreate nessecary files:
    systemctl start slapd
    systemctl stop slapd
  • Make sure OpenLDAP is NOT running, then restore from LDIF:
    slapadd -f /etc/openldap/slapd.conf -l /path/to/backup/backup.ldif
  • Start slapd:
    systemctl start slapd
  • Set correct permissions and restart slapd:
    chown ldap. /var/lib/ldap/<yourdomain>/*.bdb
    systemctl restart slapd
  • Change passwords for vmail and vmailadmin (see file):
    ldappasswd -x -h localhost -D "cn=Manager,dc=<yourdomain>,dc=com" -w <rootpass> -s <userpass> "cn=vmail,dc=<yourdomain>,dc=com"
    ldappasswd -x -h localhost -D "cn=Manager,dc=<yourdomain>,dc=com" -w <rootpass> -s <userpass> "cn=vmailadmin,dc=<yourdomain>,dc=com"
  • Verify example:
    ldapsearch -D "cn=Manager,dc=<yourdomain>,dc=com" -w password -h localhost -b "dc=<yourdomain>,dc=com"
iredmail_restore_from_ldif.txt · Last modified: 2021/10/09 15:14 by