diff options
| author | Laurent Cozic <laurent22@users.noreply.github.com> | 2018-03-18 11:55:50 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-18 11:55:50 +0000 |
| commit | 9eba8e81c4a287f6cfb21c6625fad7fbc53da050 (patch) | |
| tree | 8aad677182062335e1c7cb471cb308818196efa2 | |
| parent | 1a731243f7e32f6a7773df1f71fdcacab86efd3a (diff) | |
| parent | 9f9a4945e29448397089db36596741b977b9ef81 (diff) | |
Merge pull request #114 from neddy70/no-auto-expire
Add option to disable automatic purging of backups
| -rw-r--r-- | README.md | 5 | ||||
| -rwxr-xr-x | rsync_tmbackup.sh | 12 |
2 files changed, 17 insertions, 0 deletions
@@ -25,6 +25,7 @@ On macOS, it has a few disadvantages compared to Time Machine - in particular it --strategy Set the expiration strategy. Default: "1:1 30:7 365:30" means after one day, keep one backup per day. After 30 days, keep one backup every 7 days. After 365 days keep one backup every 30 days. + --no-auto-expire Set option to disable automatically purging old backups when out of space. ## Features @@ -91,6 +92,10 @@ To display the rsync options that are used for backup, run `./rsync_tmbackup.sh rsync_tmbackup --rsync-set-flags "--numeric-ids --links --hard-links \ --one-file-system --archive --no-perms --no-groups --itemize-changes" /src /dest + +## No automatic backup expiration + +An option to diable the default behaviour to purge old backups when out of space. This option is set with the `--no-auto-expire` flag. ## How to restore diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index cb85476..63a863f 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -46,6 +46,8 @@ fn_display_usage() { echo " --strategy Set the expiration strategy. Default: \"1:1 30:7 365:30\" means after one" echo " day, keep one backup per day. After 30 days, keep one backup every 7 days." echo " After 365 days keep one backup every 30 days." + echo " --no-auto-expire Disable automatically deleting backups when out of space. Instead an error" + echo " is logged, and the backup is aborted." echo "" echo "For more detailed help, please see the README file:" echo "" @@ -211,6 +213,7 @@ EXCLUSION_FILE="" LOG_DIR="$HOME/.$APPNAME" AUTO_DELETE_LOG="1" EXPIRATION_STRATEGY="1:1 30:7 365:30" +AUTO_EXPIRE="1" RSYNC_FLAGS="-D --compress --numeric-ids --links --hard-links --one-file-system --itemize-changes --times --recursive --perms --owner --group --stats --human-readable" @@ -242,6 +245,9 @@ while :; do LOG_DIR="$1" AUTO_DELETE_LOG="0" ;; + --no-auto-expire) + AUTO_EXPIRE="0" + ;; --) shift SRC_FOLDER="$1" @@ -455,6 +461,12 @@ while : ; do NO_SPACE_LEFT="$(grep "No space left on device (28)\|Result too large (34)" "$LOG_FILE")" if [ -n "$NO_SPACE_LEFT" ]; then + + if [[ $AUTO_EXPIRE == "0" ]]; then + fn_log_error "No space left on device, and automatic purging of old backups is disabled." + exit 1 + fi + fn_log_warn "No space left on device - removing oldest backup and resuming." if [[ "$(fn_find_backups | wc -l)" -lt "2" ]]; then |
