X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-backup-clean;h=7692145f9ab8891f1e38d9bf132397cf9540ccdc;hb=62c4ef27d7ce99c442339d4868aa75b2edadfb8f;hp=993839f78180df5c1ea2421fcf64faaf1654f5a7;hpb=ce4cacd36c5b5babeea85d0f93771017e6169180;p=distro-setup 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