Contents

Backup MySQL Databases

Backup with shell script

iRedMail ships a shell script to help backup MySQL databases: iRedMail-x.y.z/tools/backup_mysql.sh. You can always get the latest version from source code repo here: https://bitbucket.org/zhb/iredmail/src

How to restore SQL databases

You can simply restore SQL files dumped by above script.

WARNING: If you're restoring on a NEW iRedMail server, please do not restore database "mysql" exported from old server, it contains SQL usernames/passwords for Roundcube/Amavisd/Policyd/Cluebringer used on old server. New iRedMail server has the same SQL usernames, but different passwords. So please do not restore it.

Backup OpenLDAP Data

Backup with shell script

iRedMail ships a shell script to help backup OpenLDAP data: iRedMail-x.y.z/tools/backup_openldap.sh. You can always get the latest version from source code repo here: https://bitbucket.org/zhb/iredmail/src

So you should remove all files under directory "/var/lib/ldap/iredmail.org" except /var/lib/ldap/iredmail.org/DB_CONFIG.

Make sure OpenLDAP server is NOT running, then restore backup LDIF file with command "slapadd".

Terminal:

# slapadd -f /etc/openldap/slapd.conf -l /path/to/backup/backup.ldif

It's OK to start OpenLDAP server now, but it will report several errors like below:

Terminal:

# /etc/init.d/ldap start
Stopping slapd: [ OK ]
/var/lib/ldap/iredmail.org/mailMessageStore.bdb is not owned[WARNING]"
/var/lib/ldap/iredmail.org/objectClass.bdb is not owned by "[WARNING]
/var/lib/ldap/iredmail.org/mtaTransport.bdb is not owned by [WARNING]
/var/lib/ldap/iredmail.org/cn.bdb is not owned by "ldap" [WARNING]
/var/lib/ldap/iredmail.org/domainName.bdb is not owned by "l[WARNING]
/var/lib/ldap/iredmail.org/ou.bdb is not owned by "ldap" [WARNING]
/var/lib/ldap/iredmail.org/uid.bdb is not owned by "ldap" [WARNING]
/var/lib/ldap/iredmail.org/enabledService.bdb is not owned b[WARNING]
/var/lib/ldap/iredmail.org/homeDirectory.bdb is not owned by[WARNING]
/var/lib/ldap/iredmail.org/domainGlobalAdmin.bdb is not owne[WARNING]p"
/var/lib/ldap/iredmail.org/sn.bdb is not owned by "ldap" [WARNING]
/var/lib/ldap/iredmail.org/mail.bdb is not owned by "ldap" [WARNING]
/var/lib/ldap/iredmail.org/accountStatus.bdb is not owned by[WARNING]
/var/lib/ldap/iredmail.org/givenName.bdb is not owned by "ld[WARNING]
Checking configuration files for slapd: config file testing succeeded
[ OK ]
Starting slapd: [ OK ]

You must set correct file permission on newly created bdb files immediately, then restart OpenLDAP service. It won't complain incorrect file permission any more:

IMPORTANT NOTE: If you're restoring LDIF data (exported on an old iRedMail server) to a new iRedMail server, you MUST login to phpLDAPadmin on new iRedMail server and reset passwords of below two DNs. Because they're hard-coded in many config files. For example, /etc/postfix/ldap/*.cf, /etc/dovecot/dovecot-ldap.conf.

cn=vmail,dc=xxx,dc=xxx

cn=vmailadmin,dc=xxx,dc=xxx

The new passwords you should use can be found in the root directory of iRedMail installation directory on NEW iRedMail server. for example, /root/iRedMail-0.8.1/iRedMail.tips. Below is the sample of the passwords in file iRedMail.tips:

Please login to phpLDAPadmin with cn=Manager,dc=xx,dc=xx on NEW iRedMail server to reset passwords of above two DNs. Of course you can find full LDAP dn and password of 'cn=Manager,dc=xx' in iRedMail.tips.