Monday, March 25, 2013

How to sync the contents of your old Linux server to your new one

Make sure that both systems are running the same version of the same Linux distribution. Shutdown any processes that are not necessary on both servers(everything but SSH). Then run this command as root on the new server:

rsync / -av --exclude '/proc/' --exclude '/etc/hosts' --exclude '/etc/fstab' --exclude '/etc/mtab' --exclude '/etc/network/' --exclude '/dev/' --exclude '/sys/' --exclude '/var/run/utmp' --delete

Note: This will erase anything on the new server that doesn't exist on the old one. Also note that I have only tested this method with Debian and Ubuntu.