2

I have an Ubuntu installation using LVM and LUKS encryption. LVM and encryption were chosen during the install process).

While logged into it, I backup the full live system using rsync to another drive. If I ever have to restore the full system to a new hard drive, I would boot with the Ubuntu live CD and reverse the rsync command to restore everything to the new drive, and I'll fix grub and fstab. My newly restored system will work, however, this will not restore LVM or LUKS so the restored system is without these.

I was thinking, in order to keep LUKS and LVM, can I first install a fresh install of Ubuntu onto the new drive with LUKS and LVM during it's setup process, and then restore using rsync over the fresh install after mounting it in the live CD environment?

  • If you are using --one-file-system, your backup is likely incomplete. – frostschutz Sep 3 '14 at 16:23
  • I use: -aAXv --delete --progress /* /media/Backups --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs} – nLinked Sep 3 '14 at 17:51
1

If you restore on top of a fresh installation, you need to be careful to delete files that aren't being restored. Using rsync --delete during restoration will take care of that.

However, if you're going to use a live CD to restore, it may be easier to do the following:

  • Back up a complete image of your boot partition (cat /dev/sda1 >boot.image).
  • Re-create the partitions, LUKS volumes and LVM volumes and create filesystems on the logical volumes.
  • Restore the files to the empty filesystems.
  • Run grub-install or whatever command restores your bootloader.

When doing backups, I recommend that you don't traverse filesystem boundaries, i.e. pass the -x option to rsync. All kinds of directories can get mounted in weird places, for example whenever a user has found a convenient FUSE filesystem. Enumerate the mount points of your system and data directories.

rsync -aAX -x --delete / /home /media/backup

Whole-disk backups have limited use: if you accidentally delete a file, it's gone for good. Good backups keep a history. Don't do that manually, use a tool like duplicity (if you want compressed archives) or rsnapshot (if you want live files).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.