X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=ziva-backup-check;h=3db63fcd253a9bf743ebf4a3a1ec531c1bde7dc1;hb=6cc73025405b7a540eec371d1d8f7d9d13d8e019;hp=31ae7ddcf42956ffdc98723e1e6195a2270ab731;hpb=7b47d6a266340223e78317cfe0570868f45a4cad;p=distro-setup diff --git a/ziva-backup-check b/ziva-backup-check index 31ae7dd..3db63fc 100755 --- a/ziva-backup-check +++ b/ziva-backup-check @@ -18,12 +18,19 @@ fi ## begin check on btrbk -now=$(date +%s) -age_limit_sec=$(( 60 * 60 * 50 )) # 50 hours -for vol in {root,boot}_ubuntubionic; do - snaps=(/mnt/r7/amy/btrbk/${vol}.20*) +age_limit_sec=$(( 60 * 60 * 24 * 7 )) # 7 days. +for prefix in root boot; do + if [[ $prefix == boot ]]; then + # its not uncommon for the /boot subvol to have no changes, and thus + # no new backups for 10 days or so. todo: instead of this error + # prone check, we should make it so the ziva computer will + # touch a file on our computer whenever btrbk succeeds + age_limit_sec=$(( age_limit_sec + 60* 60 * 24 * 35 )) + fi + vol=${prefix}_ubuntubionic + snaps=(/mnt/r7/amy/$prefix/btrbk/${vol}.20*) if [[ ! ${snaps[*]} ]]; then - err no snapshots starting with /mnt/r7/amy/btrbk/${vol}_ubuntubionic.20 + err no snapshots starting with /mnt/r7/amy/$prefix/btrbk/${vol}.20 break fi @@ -33,13 +40,13 @@ for vol in {root,boot}_ubuntubionic; do unix_time=$(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s) printf "%s %s\n" $unix_time $s # part of the pipeline done | sort -r | head -n 1 ||: - ) + ) if [[ ! $last_snap ]]; then # should not happen. err "could not find latest snapshot for $svp among ${snaps[*]}" exit 1 fi - if (( last_snap_sec < now - age_limit_sec )); then + if (( last_snap_sec < EPOCHSECONDS - age_limit_sec )); then err vol $vol last backup older than 50 hours: $last_snap fi done