How to restore snapshot using the default layout of snapper

How to restore snapshot using the default layout of snapper

If you are using the default layout of snapper, each snapshot is sub-subvolume in the .snapshots directory of a subvolume e.g. @home.

  1. Mount btrfs root-volume into /mnt:
sudo lsblk -f   # Copy UUID of your filesystem and paste it in {XXX}
sudo mount -t btrfs -o subvol=/ /dev/disk/by-uuid/{XXX} /mnt
cd /mnt
  1. Stop all snapper services before restoring a snapshot in the live system.
    Check if snapper-XXX.timers are running, then stop them.
systemctl list-timers | grep snapper
sudo systemctl stop snapper-timeline.timer
sudo systemctl stop snapper-cleanup.timer
  1. Move a broken/old subvolume out of the way e.g. @home to @home-backup:
sudo mv @home @home-backup
  1. Restoring @home like creating a new snapshot:
sudo btrfs subvolume snapshot @home-backup/.snapshots/5/snapshot @home
  1. [IMPORTANT !!!] Get the directory .snapshots back to the healthy subvolume e.g. @home
sudo mv @home-backup/.snapshots @home/
  1. Reboot.

  2. Check if your system is ok, then delete the old/broken snapshot e.g. @home-backup or not .
    You should check if it contains useful data that you can get back.

Don’t forget to:

  • stop snapper before you do this
  • add necessary information in @home/.snapshots/5/info.xml , so you don´t confuse snapper if he sees this snapshot later
  • remove @home-backup

This works for any subvolume in a nested layout that is mounted by @name

Thanks, that is for live system, but not live USB. I edited.

That is already at the point 5.
Moving the .snapshots directory from @home-backup to @home .

But in

you create a new snapshot manually. This one has no xml-file

You create a new snapshot @home in the top level 5, it does not have info.xml.

You can not delete the snapshot if it has its sub-subvolumes in the directory .snapshots.
But you can delete it if it does not have sub-subvolumes.

I mean that people need to get useful data back from the backup-snapshot before deleting this snapshot. You do not have to delete it if some data is useful in the backup that is why deleting is optional.

People do not know how to use a flat layout of snapper. They just use the default layout, but the restoring a snapshot does not work in the default layout without moving .snapshots back.

Me too, the restoring works fine in the default layout.