Version 5 (modified by Jamie McClelland, 8 years ago) (diff)


Full Filesystem rsync

Sometimes we need to move an entire server from one machine to another machine.

The first step is to boot the target guest from a debirf image, mount all filesystem in /mnt, install rsync, and add the source server's ssh key into /root/.ssh/authorized_keys on the debirf image.

Then, on the source, edit and run the following script:

# make sure all the remote filesystems are properly mounted under /mnt

# all user/system non-temporary filesystems on the origin server:
originfilesystems="srv var home"

# -a typically means: --recursive --links --perms --times --group --owner --devices --specials
# we don't use extended attributes normally (otheriwse, we might want -X)
# or ACLs (otherwise might consider -A)

exclude="--exclude /etc/fstab --exclude /etc/network/interfaces --exclude /etc/udev/rules.d"
rsync -ax --hard-links --delete ${exclude} / "${target}"/
for fs in ${originfilesystems}; do
  echo "transfering filesystem from /${fs}"
  rsync -ax --hard-links --delete /${fs}/ "${target}/${fs}/"