{"id":2039,"date":"2013-05-06T21:19:31","date_gmt":"2013-05-06T13:19:31","guid":{"rendered":"http:\/\/rmohan.com\/?p=2039"},"modified":"2013-05-08T21:09:28","modified_gmt":"2013-05-08T13:09:28","slug":"iredmail-replication-server-with-1-hour-delay-or-what-ever-delay-you-want","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2039","title":{"rendered":"IREDMAIL replication server with 1 hour delay or what ever delay you want."},"content":{"rendered":"<p>IREDMAIL replication server with 1 hour delay or what ever delay you want.<\/p>\n<p>This is not a HA and it\u2019s not using any ldap replication engine and mysql replication engine.<\/p>\n<p>The methodology is just<\/p>\n<p>backup \u2013&gt; transfer \u2013&gt; restore<\/p>\n<p>The tools needed;<\/p>\n<p>i. rsync<\/p>\n<p>ii. NFS daemon<\/p>\n<p>iii. mysqldump and restore (for mysql)<\/p>\n<p>iv. slapcat (for ldap)<\/p>\n<p>v. crond<\/p>\n<p>Let\u2019s start<\/p>\n<p>ON THE MAIN SERVER<\/p>\n<p>1. First of all sync the data in \/var\/vmail and \/var\/www to the backup server using rsync:<\/p>\n<p>rsync -av \u2013delete \u2013stats \u2013progress \/var\/vmail\/ root@destination-host:\/var\/vmail\/<\/p>\n<p>beware of \u2013delete option, this cmd will delete data that is in backup server and not in primary server.<\/p>\n<p>2. Then sync the www folder<\/p>\n<p>rsync -av \u2013delete \u2013stats \u2013progress \/var\/www\/ root@destinan-host:\/var\/www\/<\/p>\n<p>3. Backup the mysql \u2013 all database<\/p>\n<p>mysqldump -u root -pPASSWD \u2013all-databases &gt; \/mnt\/ur-nfs-mount-folder\/all-database.sql (Please read my previous article how to setup NFS)<\/p>\n<p>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<\/p>\n<p>5. Set all cmd to the crond, for example 1 hour<\/p>\n<p>0 *\/1 * * * \/root\/rsync.sh<\/p>\n<p>&nbsp;<\/p>\n<p>ON THE BACKUP SERVER<\/p>\n<p>1. Run mysql restore<\/p>\n<p>mysql -pPASSWD &lt; \/var\/nfs\/all-database.sql<\/p>\n<p>2. Create shell script to restore ldap as follow<\/p>\n<p>#!\/bin\/bash<br \/>touch \/tmp\/ldap-restore &amp;&amp; exit<br \/>rm -rf \/var\/lib\/ldap\/domain.com\/__*<br \/>rm -rf \/var\/lib\/ldap\/domain.com\/*.bdb<br \/>rm -rf \/var\/lib\/ldap\/domain.com\/alock<br \/>rm -rf \/var\/lib\/ldap\/domain.com\/log.*<br \/>\/etc\/init.d\/ldap stop<br \/>\/usr\/sbin\/slapadd -f \/etc\/openldap\/slapd.conf -l \/var\/nfs\/backup-ldap.ldif<br \/>chown -R ldap.ldap \/var\/lib\/ldap\/domain.com\/<br \/>\/etc\/init.d\/ldap start<\/p>\n<p>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.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IREDMAIL replication server with 1 hour delay or what ever delay you want.<\/p>\n<p>This is not a HA and it\u2019s not using any ldap replication engine and mysql replication engine.<\/p>\n<p>The methodology is just<\/p>\n<p>backup \u2013&gt; transfer \u2013&gt; restore<\/p>\n<p>The tools needed;<\/p>\n<p>i. rsync<\/p>\n<p>ii. NFS daemon<\/p>\n<p>iii. mysqldump and restore (for mysql)<\/p>\n<p>iv. slapcat [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2039"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2039"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2039\/revisions"}],"predecessor-version":[{"id":2041,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2039\/revisions\/2041"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}