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 :
either to manually select it by name or entry,
or to select the last one by ID or with btrbk ls / command.
It is not possible to "automatically" select the current snapshot mounted on "/" to restore it.
Current workaround
My workaround is the following :
when creating the snapshot : doing first a btrbk dryrun to get the snapshot name and logging it in /etc/btrbk/last_snapshot.log ; then doing the btrbk run to actually create the snapshot with his own name "embedded" in it,
when restoring the snapshot : reading the value from /etc/btrbk/last_snapshot.log as the entry.
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.
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 :
btrbk ls /
command.It is not possible to "automatically" select the current snapshot mounted on "/" to restore it.
Current workaround
My workaround is the following :
btrbk dryrun
to get the snapshot name and logging it in/etc/btrbk/last_snapshot.log
; then doing thebtrbk run
to actually create the snapshot with his own name "embedded" in it,/etc/btrbk/last_snapshot.log
as the entry.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
orfindmnt
-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.