IREDMAIL replication server with 1 hour delay or what ever delay you want.

This is not a HA and it’s not using any ldap replication engine and mysql replication engine.

The methodology is just

backup –> transfer –> restore

The tools needed;

i. rsync

ii. NFS daemon

iii. mysqldump and restore (for mysql)

iv. slapcat (for ldap)

v. crond

Let’s start


1. First of all sync the data in /var/vmail and /var/www to the backup server using rsync:

rsync -av –delete –stats –progress /var/vmail/ root@destination-host:/var/vmail/ 

beware of –delete option, this cmd will delete data that is in backup server and not in primary server.

2. Then sync the www folder

rsync -av –delete –stats –progress /var/www/ root@destinan-host:/var/www/ 

3. Backup the mysql – all database

mysqldump -u root -pPASSWD –all-databases > /mnt/ur-nfs-mount-folder/all-database.sql  (Please read my previous article how to setup NFS)

4. Then run the backup script of LDAP provided by iredmail tools in /root/iRedmail/tools/ . Edit the files and change the path of destination backup to the /mnt/ur-nfs-mount-folder

5. Set all cmd to the crond, for example 1 hour

0   */1   *   *   *  /root/



1. Run mysql restore

mysql -pPASSWD < /var/nfs/all-database.sql

2. Create shell script to restore ldap as follow

touch /tmp/ldap-restore && exit
rm -rf /var/lib/ldap/*
rm -rf /var/lib/ldap/*.bdb
rm -rf /var/lib/ldap/
rm -rf /var/lib/ldap/*
/etc/init.d/ldap stop
/usr/sbin/slapadd -f /etc/openldap/slapd.conf -l /var/nfs/backup-ldap.ldif
chown -R ldap.ldap /var/lib/ldap/
/etc/init.d/ldap start

3. Run the script on crond, maybe you might set every 1hour or some minutes for giving some time for primary server to generate the backup and rsync.


This article was written by matn0t.