Articles from Rackspace's Knowledge Base.
Migrating a Linux Server From the Command Line
Stage 1
Stage 2
Stage 3
Tips For Speeding Up Rsync
A: source PC, B: target PC. Tested for ubuntu server 10.04 amd64
Check OS system version and other useful info
A$ uname -a
Install the same system (clean, obviously) in B.
Update repositories.
B$ apt-get update
Update packages
B$ apt-get upgrade
(again) Update repositories.
B$ apt-get update
(again) Update packages
B$ apt-get upgrade
Save in a text file a list of installed packages in A
A$ dpkg --get-selections > installed_packages.txt
Copy installed_packages.txt from A to B. If both are remote, use FTP over SSH to both PCs or use rcp.
Load installed_packages.txt into package manager
B$ dpkg --set-selections < /root/installed_packages_2012.07.23.txt
Install them
B$ apt-get dselect-upgrade
Create (in A) a file with all the directories and file to be excluded from replication. Some HAVE to be excluded (such as /boot, /proc and /dev) while others should be excluded. Me? This is my basic list:
/boot
/proc
/sys
/tmp
/dev
/var/lock
/etc/fstab
/etc/mdadm.conf
/etc/mtab
/etc/resolv.conf
/etc/conf.d/net
/etc/network/interfaces
/etc/networks
/etc/sysconfig/network
/etc/sysconfig/network-scripts
/etc/sysconfig/hwconf
/etc/sysconfig/ip6tables-config
/etc/sysconfig/kernel
/etc/hostname
/etc/HOSTNAME
/etc/hosts
/etc/modprobe*
/etc/modules
/etc/udev
/net
/lib/modules
/etc/rc.conf
/lost+found
/mnt
/media
/var/cache/apt/archives
Fill the file with your choices
A$ nano exclude_from_rsync.txt
Run rsync in test mode ("dry run"). IPB: IP address of B
A$ rsync -e 'ssh -p 22' --dry-run -azPx --exclude-from="exclude_from_rsync.txt" / root@IPB:/
See what will be transferred. If you notice something you would rather skip, add another entry to exclude_from_rsync.txt
Run the same command without --dry-run
That's it! You can run it again and again and only the changed files will be transmitted (rsync is quite smart).
If you were logged in in B, reboot, and try to login. You will notice the password is now the same as the one in computer A.