4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
6 base
=unison-$
(date "+%Y:%m:%d")
7 for mountp
in /mnt
/root
/mnt
/iroot
; do
8 [[ -e $mountp ]] ||
continue
9 full_base
=$mountp/$base
10 existing
=( $full_base-* )
11 if [[ -e ${existing[0]} ]]; then
12 snapshot
=$full_base-$
(( ${#existing[@]} + 1 ))
16 s btrfs subvolume snapshot
-r $mountp $snapshot
17 existing
=( $mountp/unison-
* )
18 # keep 10 unison snapshots around
19 if (( ${#existing[@]} > 10 )); then
20 IFS
=$
'\n' existing
=($
(sort -Vr <<<"${existing[*]}"))
22 s btrfs subvolume delete
${existing[@]:10}