Project

General

Profile

Bug #327

Recovering Mail Server Using Rsnapshot Backup

Added by Daniel Curtis almost 11 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Mail Server
Target version:
-
Start date:
02/04/2014
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

Description

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.

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.
    lxc-create -n mail.example.com -t debian-wheezy -f /path/to/mail.tmpl
    
  • Once this finished make the container autostart at boot on the VPS host
    ln -s /var/lib/lxc/mail.example.com/config /etc/lxc/auto/mail.example.com
    
  • Then start or log into the container
    lxc-start -n mail.example.com
    
  • Then login and change the root password, as well as run a few post installation configurations:
    passwd
    dpkg-reconfigure locales
    dpkg-reconfigure tzdata
    
  • Update and upgrade
    apt-get update
    apt-get upgrade
    
  • Join mail server to the puppet domain
    puppet agent -vt --waitforcert 30
    

    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.
      puppetca clean mail.example.com
      
  • And then on the puppet master server, sign the new puppet client certificate for the mail server.
    puppetca sign mail.example.com
    
  • This will restore the puppet clients package manifest and configurations. When this finishes, update and upgrade again.
    apt-get update
    apt-get upgrade
    

Restoring from backup

  • I copied the .tar.gz file from the NAS to /root on the mail server.
    cd /root
    cp /var/backup/2014-01-25/mail.example.com.tar.gz .
    tar xzf mail.example.com.tar.gz
    cd mail.example.com
    
  • Restore the mail server contents
    rsync -avh var/vmail /var
    
  • Restore the MySQL database
    mysql -u root -p < mysqldump/mysqldump_all_databases.sql
    
  • Restore local ispconfig folder
    rsync -avh usr/local/ispconfig /usr/local/
    
  • Restore the server configurations
    rsync -avh etc/dovecot /etc/
    rsync -avh etc/postfix /etc/
    rsync -avh etc/mailname /etc/
    rsync -avh etc/getmail /etc/
    

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.
    /usr/local/ispconfig/server/scripts/update_from_tgz.sh
    

Once the update finished I was able to control the new server from the hosting control panel. The server was successfully migrated.

#1

Updated by Daniel Curtis almost 11 years ago

  • Description updated (diff)
#2

Updated by Daniel Curtis almost 11 years ago

  • Status changed from Resolved to Closed
#3

Updated by Daniel Curtis almost 10 years ago

  • Project changed from 31 to GNU/Linux Administration
  • Description updated (diff)
  • Category set to Mail Server

Also available in: Atom PDF