LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-11-2016, 12:42 AM   #1
hruday
Member
 
Registered: Jun 2015
Posts: 88

Rep: Reputation: Disabled
how to migrate postfix to new server


We have a VM installed with centos 6.6 including postfix mail server.

Now how to migrate all users and relevant files of postfix mail server as it is to new server.

I am new to migration. So i found following related to postfix

cd /var/spool
output: anacron cron lpd mail nagios plymouth postfix

cd /etc/postfix
output: access canonical generic header_checks main.cf master.cf relocated transport virtual

what else should i take backup? and how to safely migrate to new server?
 
Old 04-11-2016, 02:26 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
postfix would be the mail transfer side of a "mail box". You most certainly also have some server for the users to access the mail. I only know dovecot for imap and pop access. Or maybe you have some webmailer? You would definitely need to move the actually mails for the users as well.

Coming down to only the postfix thing: You could setup the new server, test it and if all good you would add it to your DNS Server as the new MX record. Use a low value like 10 on it and bump up the value of the old server to like 20. This way the new server should be use by most legitimate mails coming to you.
The user part is heavily dependend on the configuration you use. Might be you only have local users (/etc/passwd) or might have virtual users. You would need to check the config for that and also which file the virtual users are in.
 
Old 04-20-2016, 05:46 AM   #3
nickmartin42
LQ Newbie
 
Registered: Mar 2016
Posts: 13

Rep: Reputation: 1
I've used this to copy over accounts. (But not mailboxes.) I don't remember where I found it, I just copied it over and saved itform My own Dynamic DNS Server..

ALWAYS TEST ANYTHING LIKE THIS BEFORE DOING IT FOR REAL!


Quote:

To copy accounts from Box1 to Box2, do the following. We need to copy the accounts from /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow, as well as the users' home and mail directories. On Box1, as root, do the following
mkdir /root/move

Set a UID limit. The default non system accounts on RH based systems begin at UID 500 and go up to 65534. (In Debian based systems, it's 2999.) We want to avoid copying over the system accounts.
export UGIDLIMIT=500

Copy /etc/passwd and /etc/group, using awk to filter out accounts with UID's under 500
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig

The following two lines are one command and should be typed on one line.
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd |tee - |egrep -f -
/etc/shadow > /root/move/shadow.mig

Copy gshadow as well--though rarely used, it won't hurt
cp /etc/gshadow /root/move/gshadow.mig


Tar and compress home and mail directories
tar zcvpf /root/move/home.tar.gz /home
tar zcvpf /root/move/mail.tar.gz /var/spool/mail

Copy the move directory to the new machine. Using scp is fine
scp -r move Box2:

On Box2 be sure to make a backup first, in case anything goes wrong. The ideal situation is one where Box2 is a brand new intall and no non-system accounts have been created, but things can easily go wrong.
mkdir /root/newusers.bak
cp -r /etc/passwd /etc/shadow /etc/group /etc/gshadkow /root/newusers.bak

Assuming that you've copied the move directory to /root on Box2 and that you are now in /root, just cd move as in the instructions below. If you've put the move directory somewhere else on Box2 or if you are in another directory there, adjust the path accordingly and replace "move" in the below commands with the path to the move directory.
cd move
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
cp gshadow.mig /etc/gshadow

(We're not as concerned about gshadow. It contains passwords for groups (rather than individuals) and probably won't affect anything.)

IMPORTANT! Note that we're doing cat >> and NOT cat >. We're appending entries to /etc/passwd, /etc/shadow and /etc/group, not overwriting them. (If you make the mistake and do cat > you can always replace the original file from the /root/newusers.bak directory that you made earlier.)

Now copy and extract the home and mail directories
cd /
tar zxvf /root/move/home.tar.gz
tar zxvf /root/move/mail.tar.gz

Reboot and accounts should be successfully moved to the new system.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to safely migrate all postfix configs and mailboxes to new server. lq_win Linux - Server 2 04-11-2016 06:26 AM
How to migrate Postfix ? dlugasx Linux - Server 1 02-20-2015 06:21 AM
How to Migrate from Qmail toaster to Postfix-Dovecot? gh0st Linux - Server 3 06-22-2009 02:04 PM
migrate from postfix to qmail izghitu Linux - Software 1 06-18-2008 02:51 PM
Migrate from postfix to postfix with my sql? res5 Debian 1 09-01-2007 12:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration