summaryrefslogtreecommitdiff
path: root/removeOldBackups.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-02-10 22:36:04 +0100
committerErich Eckner <git@eckner.net>2019-02-10 22:36:04 +0100
commit314ad8d94c5ff33fd2eadb1027748550be0e7e4f (patch)
treeb94d525ac5758380cbc8cbcc8bce8e5b68823697 /removeOldBackups.in
parent080efe8cbf8e5bc69a17f8af8f5feffd01dd67fe (diff)
downloadhardlinkedBackups-314ad8d94c5ff33fd2eadb1027748550be0e7e4f.tar.xz
camelCase -> no-camel-case, backup-progress new
Diffstat (limited to 'removeOldBackups.in')
-rwxr-xr-xremoveOldBackups.in79
1 files changed, 0 insertions, 79 deletions
diff --git a/removeOldBackups.in b/removeOldBackups.in
deleted file mode 100755
index 145a6fd..0000000
--- a/removeOldBackups.in
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-
-# removeOldBackups version #VERSION#
-
-[ -r "#ETCDIR#/backup.conf" ] && \
- . "#ETCDIR#/backup.conf"
-
-usage () {
- >&2 echo \
-'Usage: removeOldBackups [-n]
-Remove backups older than one year, keeping only one backup per month.
-
-Options:
-#HELPTEXT# #
- -n only print what would be removed'
- [ -n "$1" ] && exit $1
- exit 1
-}
-
-no_action=false
-
-if [ $# -eq 1 ]
-then
- if [ "x$1" == 'x--help' ]
- then
- usage 0
- elif [ "x$1" == 'x--version' ]
- then
- >&2 echo '#VERSION#'
- exit 0
- elif [ "x$1" == 'x-n' ]
- then
- no_action=true
- else
- usage
- fi
-elif [ $# -gt 1 ]
-then
- usage
-fi
-
-backups=$(
- printf '%s\n' "${backups[@]}" | \
- cut -d' ' -f1 | \
- while read -r dir; do \
- if [ $(ls "$dir" | wc -l) -lt 30 ]; then
- continue;
- fi
- ls -1 "$dir" | \
- sed -n '
- s,^\([0-9]\{4\}\)_\([0-9]\{2\}\)_\([0-9]\{2\}\)$,'"${dir}"'\0 \3 \2 \1 '"${dir}"',
- T
- p
- '
- done
-)
-
-{
- printf '%s\n' "${backups}" | \
- sort -k5,5 -k4,4 -k3,3 -k2,2 -k1,1 | \
- uniq -f2
- printf '%s\n' "${backups}" | \
- sed "$(
- for dist in $(seq 0 20 365); do
- printf '/ %s \S\+$/p\n' \
- "$(date '+%m %Y' -d@$(($(date +%s)-24*60*60*${dist})))"
- done | \
- sort -u
- )"
-} | \
- cut -d' ' -f1 | \
- sort | \
- uniq -u | \
- while read -r dir; do
- echo rm -rf --one-file-system "${dir}"
- if ! ${no_action}; then
- rm -rf --one-file-system "${dir}"
- fi
- done