Closed danboid closed 2 weeks ago
I have found a guide on how to do this on the Snapper page of the Arch Linux wiki, the section called "Restore using the default layout". It's quite tricky so it would be great if there was a script to automate it more. It would probably still involve having to boot SpiralLinux or another Linux from USB or the network.
https://wiki.archlinux.org/title/snapper#Restore_using_the_default_layout
I have found a Debian based guide for rolling back @home in the "Snapshots for the /home subvolume" section here:
Unfortunately we can't really just link to that guide, which I didn't properly check out until today, to answer the question of how to rollback the @home subvol snapshots.
In the intro to the guide it says "The tutorial is inspired by the SpiralLinux distribution" so I thought it would be 100% applicable but he's actually configured the subvolume layout differently and it seems a layout like his might be required to successfully roll back the @home subvol?
If you skip to the section of the guide called "Mounting the volume under /btrfsroot" you can see that he mounts his subvolmes beneath that dir.
Could it be that the current SpiralLinux subvolume config doesn't allow to rollback @home subvolumes properly?
In the final "Snapshots for the /home subvolume" section, I am unable to run a commands like these under SpiralLinux:
If you would like to take this as your current /home snapshot and remove the old one, then:
Move away the snapshot called @home:
sudo mv /btrfsroot/@home /btrfsroot/@home_old
Set the current snapshot as @home snapshot:
sudo btrfs subvol snapshot /btrfsroot/@homesnapshots/1/snapshot /btrfsroot/@home
The TLDR version of that guide for our concerns in this issue is mostly this:
Snapshots are created in read-only mode, while typical desktop environments such as KDE plasma are unable to log into a non-writable /home/
To give a snapshot write permissions, use a command like:
sudo btrfs property set -ts /home/.snapshots/1/snapshot ro false
The question is now, what are the optimal commands to rollback @home and is there already a working script available already to automate rolling back @home snapshots under SpriralLinux or do we need to write it?
The @home rollback process goes something like this:
Give the snapshot write permissions:
sudo btrfs property set -ts /home/.snapshots/1/snapshot ro false
Edit your fstab to have that particular snapshot as the mount point for /home. Where it currently says:
subvol=@home
Replace with:
subvol=@homesnapshots/.snapshots/1/snapshot
Move away the snapshot called @home:
sudo mv /btrfsroot/@home /btrfsroot/@home_old
Set the current snapshot as @home snapshot:
sudo btrfs subvol snapshot /btrfsroot/@homesnapshots/1/snapshot /btrfsroot/@home
Edit back your /etc/fstab file to have the /home path mounted like this:
subvol=@home
Reboot - e.g.:
sudo shutdown -r now
Although those commands won't work for SpiralLinux users unless they adjust their subvol config to match what David uses in his guide.
What I would personally recommend is to just:
1) Create a snapshot of your current @home
with a label like "Before rollback"
2) Delete anything or everything in your ~/
that you want to replace
3) Open the file manager to /home/.snapshots/
and pick the snapshot version to which you want to return, and copy the folders/files from there into your ~/
@geckolinux You have got a good point. I think I'm making this more complex than it needs to be.
@geckolinux One more thing before we close this please.
I don't seem to have permission to edit the SpiralLinux github wiki page when I am signed in to github. I don't really need permission to edit it if you could edit it for me?
I'd suggest we add a new bullet point to the "Working with Btrfs snapshots and rollbacks" section of https://github.com/SpiralLinux/SpiralLinux-project/wiki#working-with-btrfs-snapshots-and-rollbacks like this:
snapper-rollback
will only rollback your root (system) subvolume. If you need to restore any files or directories stored in your home directory, you can copy them from a snapshot in /home/.snapshots/
back into your home directory, if you have such snapshots availableMost users new to BTRFS will be unaware of the .snapshots dirs (per subvol) so I think this is worth a mention.
Sounds good, thanks for the suggestion, I added it to the wiki.
The SpiralLinux wiki has this section on rolling back snapper btrfs snapshots:
https://github.com/SpiralLinux/SpiralLinux-project/wiki#working-with-btrfs-snapshots-and-rollbacks
SpiralLinux includes
snapper-rollback
to make it easy to rollback the root subvolume but it doesn't have any support for easily reverting the @home subvolume snapshots, for example in the case of a user accidentally deleting all files in their home directory. Ideallysnapper-rollback
would get extended so that it could also be used with @home or other subvolumes that you have snapshots for.Correct me if I'm wrong, but I think reverting @home snapshots would involve the user booting off a live USB Linux (SpiralLinux, most likely) to replace the current @home snapshot mount point with a previous snapshot because you probably won't be able to do that whilst you have your @home home dir mounted.
Does anyone know of a guide for how to do this under Debian, ideally SpiralLinux, that we could link to or reproduce on the wiki?