Bug #327
Updated by Daniel Curtis almost 10 years ago
My mail server went down recently, and I managed to have automated rsnapshot backups going to my NAS every weekend. The following method is how I restored the virtual mail server to another virtual instance on a different machine. Luckily I use puppet for managing software packages and configuration, so I had a class for my mail server base configuration. So all I had to do was restore the vmail folder, postfix, and dovecot configurations; then run the ISPConfig update process. h2. Create New Container * I used the previous container template, @mail.tmpl@, I just changed the IP address and gateway address to the correct addresses for the new VPS host. <pre> lxc-create -n mail.example.com -t debian-wheezy -f /path/to/mail.tmpl </pre> * Once this finished make the container autostart at boot on the VPS host <pre> ln -s /var/lib/lxc/mail.example.com/config /etc/lxc/auto/mail.example.com /etc/lxc/auto/mail.altservice.com </pre> * Then start or log into the container <pre> lxc-start -n mail.example.com </pre> * Then login and change the root password, as well as run a few post installation configurations: <pre> passwd dpkg-reconfigure locales dpkg-reconfigure tzdata </pre> * Update and upgrade <pre> apt-get update apt-get upgrade </pre> * Join mail server to the puppet domain <pre> puppet agent -vt --waitforcert 30 </pre> This guide assumes that a proper puppet configuration for the mail server is present. #* * If there is a problem, it is likely that the SSL keys don't match and need to be cleaned from the puppet master server. <pre> puppetca clean mail.example.com </pre> * And then on the puppet master server, sign the new puppet client certificate for the mail server. <pre> puppetca sign mail.example.com </pre> * This will restore the puppet clients package manifest and configurations. When this finishes, update and upgrade again. <pre> apt-get update apt-get upgrade </pre> h2. Restoring from backup * I copied the @.tar.gz@ file from the NAS to @/root@ on the mail server. <pre> cd /root cp /var/backup/2014-01-25/mail.example.com.tar.gz . tar xzf mail.example.com.tar.gz cd mail.example.com </pre> * Restore the mail server contents <pre> rsync -avh var/vmail /var </pre> * Restore the MySQL database <pre> mysql -u root -p < mysqldump/mysqldump_all_databases.sql </pre> * Restore local ispconfig folder <pre> rsync -avh usr/local/ispconfig /usr/local/ </pre> * Restore the server configurations <pre> rsync -avh etc/dovecot /etc/ rsync -avh etc/postfix /etc/ rsync -avh etc/mailname /etc/ rsync -avh etc/getmail /etc/ </pre> h2. Run ISPConfig update on new virtual server * Now that all the previous server packages and configurations have been restored, run the ISPConfig update to refresh the mail server information with the hosting control panel master node. <pre> /usr/local/ispconfig/server/scripts/update_from_tgz.sh </pre> Once the update finished I was able to control the new server from the hosting control panel. The server was successfully migrated.