summaryrefslogtreecommitdiff
path: root/rsync_tmbackup.sh
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@cozic.net>2017-11-26 16:59:29 +0000
committerLaurent Cozic <laurent@cozic.net>2017-11-26 16:59:29 +0000
commit2d0cb29bcb88104e44d04aeb2860cbaf25cd32cd (patch)
treee13739b6ffca0f6d5b12551f1b67c7811beb2e3b /rsync_tmbackup.sh
parentc608793b60ced689caacded09b6da21ffa643c16 (diff)
Allow specifying the expiration strategy tokens in any order (less error prone)
Diffstat (limited to 'rsync_tmbackup.sh')
-rwxr-xr-xrsync_tmbackup.sh21
1 files changed, 10 insertions, 11 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index a22ece0..740cc1a 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -75,6 +75,15 @@ fn_parse_date() {
fi
}
+fn_run_cmd() {
+ if [ -n "$SSH_DEST_FOLDER_PREFIX" ]
+ then
+ eval "$SSH_CMD '$1'"
+ else
+ eval $1
+ fi
+}
+
fn_find_backups() {
fn_run_cmd "find "$DEST_FOLDER" -maxdepth 1 -type d -name \"????-??-??-??????\" -prune | sort -r"
}
@@ -108,8 +117,7 @@ fn_expire_backups() {
fi
# Find which strategy token applies to this particular backup
- IFS=' '
- for strategy_token in $EXPIRATION_STRATEGY; do
+ for strategy_token in $(echo $EXPIRATION_STRATEGY | tr " " "\n" | sort -r -n); do
IFS=':' read -r -a t <<< "$strategy_token"
# After which date (relative to today) this token applies (X)
@@ -161,15 +169,6 @@ fn_parse_ssh() {
fi
}
-fn_run_cmd() {
- if [ -n "$SSH_DEST_FOLDER_PREFIX" ]
- then
- eval "$SSH_CMD '$1'"
- else
- eval $1
- fi
-}
-
fn_find() {
fn_run_cmd "find '$1'" 2>/dev/null
}