[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Moving server to new server with tar



Hi,


I am in the process of moving my server to another VPS.
The goal is to keep the old VPS around and convert it to backup MX & DNS 
amongst other things. I will purchase the new VPS from another company so 
I can't just copy the vm file/container.

As a start, I would do a full tar archive of the old server and start 
from there. A test on a local VM worked, with some adjustments. Both use 
Debian 7.8. The services on the old server that need to me moved:
- Mail: Postfix, Dovecot, Spamassassin, Clamav, Postgresql, ...
- Web: nginx, supervisord, python, php5-fpm, Postgresql, ...
- DNS: PowerDNS

Tar command from the backup script on the old server:
EXCLUDE="--exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups"
tar -czpf /backups/full.tar.gz --directory=/ $EXCLUDE / 2>&1

I know I can migrate by first installing all packages, and then copying 
the config and data from one server to the other. But then you need to 
pick all data to be moved. It takes longer and it's more prone to error 
(forgetting something). I want this server to be exactly the same as the 
first one.

What I've found so far in my test:
- It's a good thing to first install all the same packages on the new 
machine first. I didn't do that in my first test and Postfix wouldn't 
come up because of Exim that was installed on the base version of the new 
OS. Simple to solve but this wouldn't have happened if I had installed 
Postfix first as Exim would have been purged.
Might be better to start with:
Old server: dpkg --get-selections > packages
New server: dpkg --set-selections < packages

- Extract the tar archive from the root on the new server
- Adjust /etc/hostname, /etc/hosts, /etc/network/interfaces
- Adjust PowerDNS settings on new server. If the new server is up I will 
need to change the PowerDNS settings on the old server as well and set up 
DNS synchronization. DNS entries at the domain registrars & reverse DNS 
will need to be changed.
- Check configs of the services above for the old ip or hostname
- Run update-grub as the id of the disk has changed.
- Reboot

This worked well, but I wonder if there are good reasons to not do move
the server like this?

Thanks for any info or insight

Regards,
Benedict


Reply to: