Friday, January 29, 2016

Migrating Mail Server from old server to new server

Postfix Mail Server Migration from old server to new server
***************************************************
First of all we will archive all existing mail userid and password.

old_server: 192.168.1.76
#########################

export UGIDLIMIT=500
#create a folder where we will store all existing mail,userid and their password. 
mkdir -p /root/migrate
cd /root/migrate

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/passfile/passwd.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/passfile/group.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/passfile/shadow.mig
cp /etc/gshadow /root/passfile/gshadow.mig

tar -zcvpf /root/migrate/home.tar.gz /home
tar -zcvpf /root/migrate/mail.tar.gz /var/spool/mail

##########################################

After that the migrate folder will be copied to New server. We will configure postfix in new server.

new_server: 192.168.1.98
#########################################


export UGIDLIMIT=500
mkdir -p /root/backup
cd /root/backup
scp 192.168.1.76:/root/migrate/* .
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
cp gshadow.mig /etc/gshadow
cd /
tar -zxvf /root/backup/home.tar.gz
tar -zxvf /root/backup/mail.tar.gz



1 comment: