digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.58k stars 116 forks source link

Feature request : BTRBK + grub-btrfs - Restore the snapshot currently booted - like Timeshift #580

Open matleborgne opened 5 months ago

matleborgne commented 5 months ago

Usecase description

When using grub-btrfs in addition to BTRBK, it is possible to boot on a selected snapshot in grub.

To restore a snapshot, it is then mandatory :

It is not possible to "automatically" select the current snapshot mounted on "/" to restore it.

Current workaround

My workaround is the following :

This works as intended, because the /etc/btrbk/last_snapshot.log in the snapshot is the one just before the snapshot was actually made (overwritten with each snapshot).

However, this is not a "clean way" to do it, as I have to set "timestamp_format short" to avoid logging a wrong name, and not lauching the full command near to midnight as it could as well logging a wrong name.

Precision : Neither blkid, lsblk, mount or findmnt -like commands seems to be able to know we booted on a btrfs snapshot, which seems strange (but I'm not a btrfs expert). This is why I let down the idea of getting the current booted snapshot name during the restoring phase.

EDIT : I found another workaround using dmesg boot logs, which has to be done from the snapshot itself.

dmesg | grep "Command line"