From 1987656b0e0287fc1b04958216b8c8dd9049d77c Mon Sep 17 00:00:00 2001 From: michele Date: Fri, 28 Mar 2014 00:43:35 +0100 Subject: [PATCH] do not remove local bk if upload failed --- README.md | 8 +++++++- zfsbk.sh | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7e1984d..923cda1 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,12 @@ variables: # take selective backup EXTRA_EXCLUDES="/jails/test.dom.com" /usr/local/sbin/zfsbk.sh mybk 1 +`zfsbk.sh` maintains serialized backups in directory `/backups` after having uploaded them. +If you want to cleanup the backup file locally after uploading it upstream, set the +`CLEAR_BKFILE` environment variable to a non-empty value. `zfsbk.sh` will maintain the local +backup regardless of this variable if the upload failed. + + # Managing multiple ZFS Pools Simply run these scripts once for each pool, setting the _ZPOOL_ environment variable @@ -215,7 +221,7 @@ tested for a number of scenarios, and used in a number of servers. Because of the inherently partial nature of testing, you are aware that this brings no guarantees that it'll work for your scenario. -Careful yourself when working with ZFS snapshots! Check this out: +**Careful yourself** when working with ZFS snapshots! Check this out: zfs destroy -r zroot@mysnap # destroy snapshot 'mysnap' from pool 'zroot' zfs destroy -r zroot#mysnap # destroy all system data, and comment it's 'mysnap' diff --git a/zfsbk.sh b/zfsbk.sh index 8dd4293..b0948df 100755 --- a/zfsbk.sh +++ b/zfsbk.sh @@ -114,11 +114,11 @@ then echo "Expecting rsync://.. or scp://.." exit 1 fi -fi - -# remove backup file if requested -if [ "x$CLEAR_BKFILE" != x ] -then - rm -f $bkfile + # remove local backup if requested & upload was successful + if [ $? -eq 0 -a "x$CLEAR_BKFILE" != x ] + then + # remove backup file if requested + rm -f $bkfile + fi fi