Restore a machine from a backup

It is very easy under GNU/Linux to restore a system from a full rsync backup. Just follow this procedure:

  • Boot on a liveCD
  • In case of hard-drive change, partition the new HDD using parted
  • Create a temporary directory and mount the root partition of you HDD inside (/dev/sdb1 in this example):
mkdir /mnt/root_hdd
mount -t ext3 /dev/sdb1 /mnt/root_hdd
  • Restore data from your backup:
rsync -av --numeric-ids --delete --exclude='/proc' --exclude='/sys' /media/<mybackup>/ /mnt/root_hdd/

Data from the root partition will be overwritten, and supernumerary files deleted.

Now in case of disk change, we need to take care of the boot loader also:

  • Install grub:
mount --bind /proc /mnt/root_hdd/proc
mount --bind /dev /mnt/root_hdd/dev
mount --bind /sys /mnt/root_hdd/sys
chroot /mnt/root_hdd
grub-install /dev/sdb1

That’s all, reboot and enjoy.

Remount a filesystem as read/write

Sometimes due to a failed update or a bad manipulation you may end up with no other choice then reboot your system into ‘recovery mode‘. In this setting the root partition is mounted in read only. To remount it in read/write:

# mount -o remount,rw /