You are on page 1of 2

Backing Up and restoring Qmail with Vpopmail,courier imap,squirrelmail

# Refrences:
# http://forum.qmailrocks.org/showthread.php?t=4800&highlight=backup
# http://goodcleanemail.com/kb.php?ToDo=view&questId=56&catId=5
# http://qmailrocks.org/maintain.php#backup
# http://www.squirrelmail.org/wiki/UpgradingSquirrelMail

Backing Up Qmail and Vpopmail and squirrelmail

# Backup the accounts in vpopmail

cd /home/vpopmail/domains

vi find_vpopmail_users

####
for domain in *;do for user in `ls $domain`; do echo -n "~vpopmail/bin/vadduser"
$user@$domain; ~vpopmail/bin/vuserinfo $user@$domain |grep -v "name:\|^passwd:" |
sed -e 's/clear passwd://'; done; done | grep -v "no such"| grep @ |sort

###

chmod 755 find_vpopmail_users

./find_vpopmail_users > generated_vpopmail_accounts

# Make sure you trim the unnecessary lines at the top of the file
generated_vpopmail_accounts.Copy #this script generated_vpopmail_accounts to your
new server and execute it there.

#Backup the following Directories

/home/vpopmail - backs up all your domain information, including mailboxes,


passwords and the messages themselves.

/var/qmail - backs up all of your qmail settings. The /var/qmail/control directory


is the most important directory in there to back up, but it won't hurt to just
back up the whole damn qmail directory.

/usr/share/squirrelmail
/var/www/webmail

/var/www/cgi-bin
/var/www/html

# Restoring Qmail and Vpopmail

# You will need to create your domain manually on the new server by following
these steps

# For virtual domains

/home/vpopmail/bin/vadddomain <yourdomain.com> <postmaster_password>

# For Alias domains


/home/vpopmail/bin/vaddaliasdomain <new domain> <old domain>

Reference:http://forum.qmailrocks.org/showthread.php?t=4800&highlight=backup to
backup and restore acounts.
# Execute the script generated_vpopmail_accounts copied from your old server
#This will create all your user accounts in the new server

# Restoring yoru emails using rsync

# Generate DSA keys

#On your old server do this as root.


cd /root

ssh-keygen -t dsa -b 1024 -f root_dsa -C 'Root dsa key'

mv root_dsa /root/.ssh/

scp -P222 root_dsa.pub root@new_server:/tmp

# On your new server


cat /tmp/root_dsa.pub >> /root/.ssh/authorized_keys

chmod 600 /root/.ssh/authorized_keys

rm -rf /tmp/root_dsa.pub

# Please ensure that the following entries are present in your new servers
/etc/sshd/sshd_config file or else your public key authentication wont work
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

# Restore your email as follows

# Restoring all emails in a domain


rsync -avuzr --stats --delete -e "ssh -p222 -i /root/.ssh/root_dsa"
/home/vpopmail/domains/<your domainname>
root@new_server_ip:/home/vpopmail/domains/

#Restoring a particular users email


rsync -avuzr --stats --delete -e "ssh -p222"
/home/vpopmail/domains/<yourdomain.com>/username
root@new_server_ip:/home/vpopmail/domains/<yourdomain.com>/

# Restore squirrelmail as explained in


http://www.squirrelmail.org/wiki/UpgradingSquirrelMail

You might also like