From 4250423d98de817154bbf653f205e1377e66fc10 Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Thu, 14 Nov 2013 18:50:34 -0800 Subject: [PATCH] Make fn_expire_backup more robust. --- rsync_tmbackup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 7b0f7a6..5e12eda 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -41,6 +41,13 @@ fn_find_backups() { } fn_expire_backup() { + # Double-check that we're on a backup destination to be completely + # sure we're deleting the right folder + if [ "$(fn_is_backup_destination $(dirname -- "$1"))" != "1" ]; then + fn_log_error "$1 is not on a backup destination - aborting." + exit 1 + fi + fn_log_info "Expiring $1" rm -rf -- "$1" } @@ -258,13 +265,6 @@ while [ "1" ]; do exit 1 fi - # Double-check that we're on a backup destination to be completely sure we're deleting the right folder - OLD_BACKUP_PARENT_PATH=$(dirname -- "$OLD_BACKUP_PATH") - if [ "$(fn_is_backup_destination $OLD_BACKUP_PARENT_PATH)" != "1" ]; then - fn_log_error "'$OLD_BACKUP_PATH' is not on a backup destination - aborting." - exit 1 - fi - fn_expire_backup "$OLD_BACKUP_PATH" # Resume backup