Knowledge Base » Documentation MailCleaner »
Cloning the same MailCleaner
Julien Groselle
Added over 9 years ago
This procedure DOES NOT apply to creating an extra node for the cluster. These instructions are for the emergency recovery of a MailCleaner system which is broken at the OS level, or for migrating to a fresh base OS. It will give you the exact same MailCleaner configuration, including the expectation that it fill the same role in the cluster as the existing MailCleaner by migrating all of the data from one MailCleaner server to another.
To be clear the server we want to replace will be named server01 and the new one, server02
Preparation :¶
- First, you need to ensure that server02 has completed installation of add-ons, initial configuration and updates. Verify that it is registered with the same credentials as server01 at Configuration->Base system->Registration, and verify that
/root/Updater4MC/updater4mc.sh
has successfully completed all updates. - You will need to prepare for server01 to be taken out of service. If server02 is not going to re-use an identical hostname and IP, you will need to modify the MX records accordingly (including possibly redirecting directly to the mail server temporarily if you want zero downtime). Also be sure to remove server01 as an outgoing relay if it is currently used as one.
- If you are going to re-use the same hostname and IP for server02, be sure to follow those optional steps below.
Stop MailCleaner on server01 and server02¶
/etc/init.d/mailcleaner stop
Copy the system configuration and data¶
There are two ways to do this :
Direct Copy¶
Use rsync to copy all of the data over the network:
rsync -av --delete --exclude 'spool/tmp' /var/mailcleaner/* root@server02:/var/mailcleaner/
Also copy the main configuration file:
rsync -av /etc/mailcleaner.conf root@server02:/etc/mailcleaner.conf
(Optional) If you will be re-using the same hostname and IP, then copy the networking configuration:
rsync -av /etc/network/interfaces root@server02:/etc/network/interfaces
Archive, Copy and Extract¶
Make a tar compressed archive
cd /var && tar -cvzf mailcleaner_data.tgz mailcleaner/
Copy the archive mailcleaner_data.tgz
to server02.
Also copy the main configuration file /etc/mailcleaner.conf
(and optionally, the networking configuration file /etc/network/interfaces
) to server02, overwriting the existing files.
On server02, move the existing mailcleaner folder :
cd /var && mv mailcleaner mailcleaner_old
then extract the archive :
tar -xvzf /var/tmp/mailcleaner_data.tgz
Final Steps¶
Delete temporary files on server02
rm -rf /var/mailcleaner/spool/tmp/*
Shutdown, or at least disable networking on server01:
halt # or /etc/init.d/networking stop
If you are re-using the same hostname and IP, then you will need to restart the network services on server02 to take over server01's now free IP:
/etc/init.d/networking restart
Now start MailCleaner on server02. All the datas (databases, quarantine) from server01 will now be present on server02:
/etc/init.d/mailcleaner start
Ensure that the database has initialized correctly by running a check and repair command. If the server you want to clone is the master :
/usr/mailcleaner/bin/check_db.pl -m --myrepair
If the server you want to clone is a slave :
/usr/mailcleaner/bin/check_db.pl -s --myrepair
Clustering¶
If it is a member of a cluster, and you have re-used the same hostname and IP, server02 should seamlessly take over the role of server01. If you only have a one-node cluster, you will also not need to do anything, since it is not in a cluster to begin with. Otherwise, if the node is the member of a cluster, you may need to reconfigure the cluster.
If the node is a Master, then you will need to run /usr/mailcleaner/scripts/configuration/slaves.pl
on each of the Slave nodes and use 5) set this host as slave
configure the new hostname or IP of server02.
If the node is a Slave, then you will need to run /usr/mailcleaner/scripts/configuration/slaves.pl
on the Master and use 3) delete slave
, then 4) add slave
to remove server01 from the cluster (by it's ID, check 2) view slaves
first if you don't know it), then re-add server02 with the same ID.