From: Ian Kelling Date: Tue, 16 May 2023 01:27:38 +0000 (-0400) Subject: fix mail backup expiration X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=commitdiff_plain;h=d1699bf542263f68d15c48751826bb740916b3d9 fix mail backup expiration --- diff --git a/btrbk-run b/btrbk-run index 92e6967..24efc0f 100644 --- a/btrbk-run +++ b/btrbk-run @@ -299,11 +299,7 @@ if [[ ! -v targets && ! $source ]]; then fi done elif $at_work; then - if ping -q -c1 -w1 iank.vpn.office.fsf.org &>/dev/null; then - targets+=(iank.vpn.office.fsf.org) - else - targets+=(i.b8.nz) - fi + targets+=(i.b8.nz) for h in x2 x3 kw; do if [[ $HOSTNAME == "$h" ]]; then continue @@ -563,11 +559,11 @@ snapshot_create onchange # if one disk had less space. # for now, keeping them equal. snapshot_preserve $std_preserve -snapshot_preserve_min 2h +snapshot_preserve_min 6h snapshot_dir btrbk # so, total backups = ~58 target_preserve $std_preserve -target_preserve_min 2h +target_preserve_min 6h # i tried this when investigating: clone no source subvolume found error #incremental_prefs sro:1 srn:1 sao san:1 aro:1 arn:1 @@ -703,7 +699,7 @@ fi if [[ $ret == 0 ]]; then for tg in ${targets[@]}; do : - #ssh root@$tg /a/exe/mail-backup-clean + ssh root@$tg /a/exe/mail-backup-clean done fi diff --git a/mail-backup-clean b/mail-backup-clean index 993839f..7692145 100755 --- a/mail-backup-clean +++ b/mail-backup-clean @@ -18,9 +18,16 @@ shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR -cd /mnt/o/btrbk -tmp=(o*) -last_snap_date=${tmp[-1]#o.} -time=$(( $(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<$last_snap_date) +%s) -1 )) -# 1 second granularity, so we could have a duplicate file, oh well, not worrying about that. -find /bu/md -type f \! -newermt @$time -delete +## This would delete backups that we already have in snapshots, +## 1 second granularity, so we could have some duplicates. However, +## this doesn't account for files received then accidentally deleted, +## all in between two snapshots, so they aren't in any snapshot. +## So, instead, just keep a bunch of backups based on time. + +# cd /mnt/o/btrbk +# tmp=(o*) +# last_snap_date=${tmp[-1]#o.} +# time=$(( $(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<$last_snap_date) +%s) -1 )) +# find /bu/md -type f \! -newermt @$time -delete + +find /bu/md -type f -mtime +100 -delete