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