{"id":105,"date":"2012-07-04T12:05:10","date_gmt":"2012-07-04T04:05:10","guid":{"rendered":"http:\/\/matnet.my\/blog\/?p=105"},"modified":"2012-07-04T12:05:10","modified_gmt":"2012-07-04T04:05:10","slug":"iredmail-replication-server-with-1-hour-delay-or-what-ever-delay-you-want","status":"publish","type":"post","link":"https:\/\/matnet.my\/blog\/2012\/07\/iredmail-replication-server-with-1-hour-delay-or-what-ever-delay-you-want\/","title":{"rendered":"IREDMAIL replication server with 1 hour delay or what ever delay you want."},"content":{"rendered":"<p>This is not a HA and it&#8217;s not using any ldap replication engine and mysql replication engine.<\/p>\n<p>The methodology is just<\/p>\n<p>backup &#8211;&gt; transfer &#8211;&gt; restore<\/p>\n<p><strong>The tools needed;<\/strong><\/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&#8217;s start<\/p>\n<p><strong>ON THE MAIN SERVER<\/strong><\/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><strong><em>rsync -av &#8211;delete &#8211;stats &#8211;progress \/var\/vmail\/ root@destination-host:\/var\/vmail\/\u00a0<\/em><br \/>\n<\/strong><\/p>\n<p>beware of &#8211;delete 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><strong><em>rsync -av &#8211;delete &#8211;stats &#8211;progress \/var\/www\/ root@destinan-host:\/var\/www\/\u00a0<\/em><\/strong><\/p>\n<p>3. Backup the mysql &#8211; all database<\/p>\n<p><strong><em>mysqldump -u root -pPASSWD &#8211;all-databases &gt; \/mnt\/ur-nfs-mount-folder\/all-database.sql\u00a0<\/em> <\/strong> (Please read my previous article how to setup NFS)<strong><em><br \/>\n<\/em><\/strong><\/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\u00a0\u00a0 *\/1\u00a0\u00a0 *\u00a0\u00a0 *\u00a0\u00a0 *\u00a0 \/root\/rsync.sh<\/p>\n<p>&nbsp;<\/p>\n<p><strong>ON THE BACKUP SERVER<\/strong><\/p>\n<p>1. Run mysql restore<\/p>\n<p><em><strong>mysql -pPASSWD &lt; \/var\/nfs\/all-database.sql<\/strong><\/em><\/p>\n<p>2. Create shell script to restore ldap as follow<\/p>\n<p><strong><em>#!\/bin\/bash<\/em><\/strong><br \/>\n<strong><em>touch \/tmp\/ldap-restore &amp;&amp; exit<\/em><\/strong><br \/>\n<strong><em>rm -rf \/var\/lib\/ldap\/domain.com\/__*<\/em><\/strong><br \/>\n<strong><em>rm -rf \/var\/lib\/ldap\/domain.com\/*.bdb<\/em><\/strong><br \/>\n<strong><em>rm -rf \/var\/lib\/ldap\/domain.com\/alock<\/em><\/strong><br \/>\n<strong><em>rm -rf \/var\/lib\/ldap\/domain.com\/log.*<\/em><\/strong><br \/>\n<strong><em>\/etc\/init.d\/ldap stop<\/em><\/strong><br \/>\n<strong><em>\/usr\/sbin\/slapadd -f \/etc\/openldap\/slapd.conf -l \/var\/nfs\/backup-ldap.ldif<\/em><\/strong><br \/>\n<strong><em>chown -R ldap.ldap \/var\/lib\/ldap\/domain.com\/<\/em><\/strong><br \/>\n<strong><em>\/etc\/init.d\/ldap start<\/em><\/strong><\/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.<br \/>\n-EoF-<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is not a HA and it&#8217;s not using any ldap replication engine and mysql replication engine. The methodology is &hellip; <a href=\"https:\/\/matnet.my\/blog\/2012\/07\/iredmail-replication-server-with-1-hour-delay-or-what-ever-delay-you-want\/\" class=\"more-link\">More <span class=\"screen-reader-text\">IREDMAIL replication server with 1 hour delay or what ever delay you want.<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,3],"tags":[],"class_list":["post-105","post","type-post","status-publish","format-standard","hentry","category-bsd-nix","category-www","standard"],"_links":{"self":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/comments?post=105"}],"version-history":[{"count":1,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts\/105\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts\/105\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/media?parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/categories?post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/tags?post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}