3 [[ $EUID == 0 ]] ||
exec sudo
-E "$BASH_SOURCE" "$@"
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
15 if [[ ! $snaps ]]; then
19 # when a btrbk bugfix makes it into the distro,
20 # we might replace this with btrbk list latest /mnt/root/$vol | ...
21 # note: this is duplicated in mount-latest-subvol
23 for f
in ${snaps[@]}; do
24 printf "%s %s\n" $
(date -d $
(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s
) $f
25 done |
sort -r |
head -n 1 |
awk '{print $2}'
27 if [[ ! $last_snap ]]; then
33 if btrfs sub show
$d|
sed '0,/^\t*Snapshot(s):/d;s/^\s*//' | \
34 grep -xF btrbk
/$last_snap &>/dev
/null
; then
37 last_uuid
=$
(btrfs sub show
$last_snap|
awk '$1 == "UUID:" {print $2}')
38 if btrfs sub show
$d|
grep "^\s*Parent UUID:\s*$last_uuid$" &>/dev
/null
; then
42 stale_dir
=/nocow
/btrfs-stale
43 stale_file
=$stale_dir/$vol
46 printf "%s\n" $last_snap > $stale_file
56 # todo: figure out what to do when there are no
57 # snapshots yet. I guess that should be
58 # yes to being stale? see the implications
59 # in the other script.