diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/backup-clean | 10 | ||||
| -rwxr-xr-x | bin/byo | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/bin/backup-clean b/bin/backup-clean index 0c6e38a..30d25db 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -54,11 +54,12 @@ retention_delay() { } dest=/.history -while getopts :nv opt; do +while getopts :d:nv opt; do case $opt in + (d) tsn=$(date2ts "$OPTARG") ;; (n) optn=1 ;; (v) optv=1 ;; - (*) echo "Usage: $0 [-nv] [dir]"; exit 1; + (*) echo "Usage: $0 [-nv] [dir]"; exit 1 ;; esac done shift $((OPTIND - 1)) @@ -66,6 +67,8 @@ shift $((OPTIND - 1)) # Sorted list of backups, most recent first. lbu=$(ls -rv "$dest") +lasy=${lbu##* +} for d in $lbu; do tsc=$(date2ts "$d") if ! [ "$tsp" ]; then @@ -75,7 +78,8 @@ for d in $lbu; do fi mrd=$(retention_delay "$tsp") dp=$((tsp - tsc)) - if [ $((dp < mrd)) = 1 ]; then + #if [ $((dp < mrd)) = 1 ]; then + if [ "$d" != "last" -a $((dp < mrd)) = 1 ]; then [ "$optv" ] && echo "delete $dest/$d" [ "$optn" ] || rm -rf "${dest:?}/$d" else @@ -11,9 +11,9 @@ Options: -k do not umount and close yoda ' -while getopts :cdk opt; do +while getopts :Ccdk opt; do case $opt in - (c|d|k) eval "opt$opt=$opt" ;; + (C|c|d|k) eval "opt$opt=$opt" ;; (*) printf %s "$usage"; exit 1 ;; esac done @@ -25,9 +25,10 @@ dest=/mnt/backup/$(hostname) [ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt time backup -v -d "$dest" -backup -v -d "$dest" clean +[ ! "$optC" ] || backup -v -d "$dest" clean [ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest" df -h / "$dest" +ls -v "$dest" [ ! "$optk" ] || noumount=1 noclose=1 [ ! "$optc" ] || noumount='' noclose='' [ "$noumount" ] || umount /mnt |
