From dd9d3dc982eacf1c2eacef1a9b4c7911bffb611f Mon Sep 17 00:00:00 2001 From: deajan Date: Thu, 8 Jan 2015 17:16:57 +0100 Subject: [PATCH] Added --delete option for backups --- CHANGELOG.md | 1 + host_backup.conf | 5 ++++- obackup.sh | 13 +++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2392ac..7b9012a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ UNDER WORK CHANGELOG --------- +- Added delete on destination option for files that vanished from source - Fixed ignoring compression level in conf file - Fixed dry mode sql backup output - Prevented triggering TrapError if there are no child processes to terminate on TrapQuit diff --git a/host_backup.conf b/host_backup.conf index 0f3c17a..4c674d7 100755 --- a/host_backup.conf +++ b/host_backup.conf @@ -2,7 +2,7 @@ ###### Remote (or local) backup script for files & databases ###### (L) 2013 by Ozy de Jong (www.netpower.fr) -###### Config file rev 2711201401 +###### Config file rev 0801201501 ## ---------- GENERAL BACKUP OPTIONS @@ -139,6 +139,9 @@ HARD_MAX_EXEC_TIME_FILE_TASK=7200 ## Keep partial uploads that can be resumed on next run, experimantal feature PARTIAL=no +## Delete files on destination that vanished from source. Do not turn this on unless you enabled backup rotation or a snapshotting FS like zfs to keep those vanished files on the destination. +DELETE_VANSIHED_FILES=no + ## ---------- ALERT OPTIONS ## Alert email adresses separated by a space character diff --git a/obackup.sh b/obackup.sh index 7b88199..8aa596c 100755 --- a/obackup.sh +++ b/obackup.sh @@ -5,7 +5,7 @@ AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.84RC4 -PROGRAM_BUILD=2112201402 +PROGRAM_BUILD=0801201501 ## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode if ! type -p "$BASH" > /dev/null @@ -1280,6 +1280,11 @@ function Init RSYNC_EXCLUDE="$RSYNC_EXCLUDE --exclude=\"$PARTIAL_DIR\"" fi + if [ "DELETE_VANSIHED_FILES" == "yes" ] + then + SYNC_OPTS=$SYNC_OPTS" --delete" + fi + if [ $stats -eq 1 ] then SYNC_OPTS=$SYNC_OPTS" --stats" @@ -1424,7 +1429,8 @@ function Usage echo "--verbose: adds command outputs" echo "--stats Adds rsync transfer statistics to verbose output" echo "--partial Allows rsync to keep partial downloads that can be resumed later (experimental)" - echo "--no-maxtime: disables any soft and hard execution time checks" + echo "--no-maxtime disables any soft and hard execution time checks" + echo "--delete Deletes files on destination that vanished on source" exit 128 } @@ -1470,6 +1476,9 @@ do --no-maxtime) no_maxtime=1 ;; + --delete) + DELETE_VANSIHED_FILES="yes" + ;; --help|-h|--version|-v) Usage ;;