The best sanity check is to actually boot from the backup.
That is the only way to be 100% sure, by testing it for real!
You wont be able to do that from a folder inside root as far I know. (Actually, the destination I use is "a folder inside root tree" but at /media/$USER/RootBackup that is actually another filesystem.) You wont even need to restore the backup to promptly use it, in case you are in a hurry and something bad happens, just boot from the backup, and restore it later!
With rsync, it is quite fast to just update a backup of the root any time you need. I do it everytime before I am going to update kernel and other core packages on ubuntu 20.04.
Obs.: In case you use LVM too, I discarded LVM snapshot as an option for being extremelly slow.
I am using this command:
sudo rsync -axHAXv --delete-excluded / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /media/$USER/RootBackup/
I run it a few subsequent times to grant no important files changed.
The importance of --delete-excluded is to really keep it in sync (identical).
I also backup /boot separately because it is another partition mounted there, with:
sudo rsync -axHAXv --delete-excluded /boot/ --exclude=/lost+found /media/$USER/RootBackup/boot/
After the first time you run it, do this:
grub-update
but it did not work properly here, it kept pointing to the LVM device, instead of the new filesystem I created, so I did this:
mount |grep RootBackup #copy the device name, ex.: sdb4 ls /dev/disk/by-uuid/ -l |grep sdb4 # copy the UUID ex.: 4e97fe69-93ae-4e6a-a2cc-3406cb21176c
now copy the new menuentry from grub.cfg to /boot/grub/custom.cfg (I use gpt here, you may not need this, just copy and modify the menuentry generated by grub-update as needed):
menuentry 'RootBackup by UUID' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'osproberfailed-manualadjustment-gnulinux-simple-4e97fe69-93ae-4e6a-a2cc-3406cb21176c' { insmod part_gpt insmod ext2 set root='hd3,gpt13' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd3,gpt13 --hint-efi=hd3,gpt13 --hint-baremetal=ahci3,gpt13 4e97fe69-93ae-4e6a-a2cc-3406cb21176c else search --no-floppy --fs-uuid --set=root 4e97fe69-93ae-4e6a-a2cc-3406cb21176c fi linux /boot/vmlinuz root=UUID=4e97fe69-93ae-4e6a-a2cc-3406cb21176c ro quiet splash $vt_handoff debug --verbose initrd /boot/initrd.img }
obs.: the important modifications needed after the grub-update auto generated menuentry were:
- grant the corret UUID was set. Note that
search and linux commands are using the same UUID, as the whole backup ended up in a single partition. - vmlinuz and initrd had to be searched at "/boot/" and are using the automatic symlink to not require maintenance
- linux command had to use
root=UUID=... because /dev/sdb4 randomly changed to sdc4 and was unreliable - dont use the PARTUUID as it wont work.
To restore, boot from the backup, so the source path will be /, but the destination will be something else that you will have to mount.
Just in case you do not run the main root backup procedure for too long:
- boot from the working backup root
- create a second backup from the main root FS
- restore the working backup root over the main root FS
- boot from the main root FS
- as soon you find something is missing or wrong, get what you need from the second backup you just created.
I hope you can be as tranquil as I am now on a desktop PC, w/o no-break, and needing to update core system files with critical updates! :)