hirak99 / yabsnap

Btrfs Scheduled Snapshot Manager for Arch
Apache License 2.0
60 stars 2 forks source link

Does this tool support online rollback? #37

Open developer91234 opened 1 month ago

developer91234 commented 1 month ago

Not clear from the documentation and I don't have an arch btrfs system to test. Would you be able to rollback the mounted root subvolume in place? Also, if I were booted into a snapshot, the rollback script would rollback the root subvolume, correct?

hirak99 commented 1 month ago

Yes, online rollback is supported.

The yabsnap rollback-gen ID command generates a short bash script.

You will need to review the script and run it manually (or type in the commands one by one).

It can be run from the system mounted on the root which you want to roll back. After you run the script, the system will continue to function with the current snapshot until you reboot, upon which the rollback will take effect.

For rollback to work correctly, root should be mounted (in fstab) with subvol= and not subvolid=.

hirak99 commented 1 month ago

Also fyi, here's an example of rollback script it generates. This should clarify exactly how the rollback process works.

Command -

$ yabsnap rollback-gen 20240728183030

Output -

#!/bin/bash
# Save this to a script, review and run as root to perform the rollback.

set -uexo pipefail

mkdir -p /run/mount/_yabsnap_internal_0
mount /dev/mapper/luksdev /run/mount/_yabsnap_internal_0 -o subvolid=5

cd /run/mount/_yabsnap_internal_0

mv @home @.snapshots/rollback_20240728192848_@home
btrfs subvolume snapshot /.snapshots/@home-20240728183030 @home

mv @ @.snapshots/rollback_20240728192848_@
btrfs subvolume snapshot /.snapshots/@root-20240728183030 @

echo Please reboot to complete the rollback.
echo
echo After reboot you may delete -
echo "# sudo btrfs subvolume delete /.snapshots/rollback_20240728192848_@home"
echo "# sudo btrfs subvolume delete /.snapshots/rollback_20240728192848_@"
developer91234 commented 1 month ago

Thanks. Please consider letting the user do rollbacks without saving the script as this is quite cumbersome. After all the operation is reversible, maybe just inform the user of the changes after they're done and allow them to undo it if they want.