2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
5 source /a
/bin
/errhandle
/err
7 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
10 err
() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
12 ## begin check on syncthing
13 if ! systemctl show
--no-page syncthing@ziva |
sed -n 's/^MainPID=//p' |
egrep '^[0-9]+$' &>/dev
/null
; then
14 err no pid
for syncthing@ziva. systemctl status
:
15 systemctl status syncthing@ziva
17 ## end check on syncthing
20 ## begin check on btrbk
22 age_limit_sec
=$
(( 60 * 60 * 50 )) # 50 hours
23 for vol
in {root
,boot
}_ubuntubionic
; do
24 snaps
=(/mnt
/r
7/amy
/btrbk
/${vol}.20*)
25 if [[ ! ${snaps[*]} ]]; then
26 err no snapshots starting with
/mnt
/r
7/amy
/btrbk
/${vol}_ubuntubionic
.20
30 read last_snap_sec last_snap
< <(
31 for s
in ${snaps[@]}; do
33 unix_time
=$
(date -d $
(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s
)
34 printf "%s %s\n" $unix_time $s # part of the pipeline
35 done |
sort -r |
head -n 1 ||
:
37 if [[ ! $last_snap ]]; then
39 err
"could not find latest snapshot for $svp among ${snaps[*]}"
42 if (( last_snap_sec
< now
- age_limit_sec
)); then
43 err vol
$vol last backup older than
50 hours
: $last_snap