diff --git a/zfs-backup.cfg b/zfs-backup.cfg index 7f33fa4..c12b764 100644 --- a/zfs-backup.cfg +++ b/zfs-backup.cfg @@ -1,14 +1,17 @@ # required format: -# SOURCE TARGET KEEPDAYS ENABLED -# dataset [user@host:]dataset number Y or N +# SOURCE TARGET KEEPDAYS MODE ENABLED +# dataset [user@host:]dataset number backup or sync Y or N # we are securing this elsewhere; if we are using this method, we'll need to configure the target host # 'user' needs an authorized and restricted public key for SSH access and sudoer rights on 'remotehost' to execute the following as root: # /usr/sbin/zfs recv -Feuv datapool/backup, /usr/sbin/zfs destroy -r datapool/backup/* -data/home user@remotehost:datapool/backup 7 Y +data/home user@remotehost:datapool/backup 7 backup Y -# this goes to another pool on this host so no further configuration is necessary -data/config backup/data 5 Y +# this goes to another pool on this host so no further configuration is necessary +data/config backup/data 5 backup Y # we no longer back this up -data/volatile backup/data 2 N +data/volatile backup/data 2 backup N + +# we only sync this one +data/replica remote/dump 31 sync Y diff --git a/zfs-backup.sh b/zfs-backup.sh index 3a4f563..2dd6b53 100755 --- a/zfs-backup.sh +++ b/zfs-backup.sh @@ -76,7 +76,7 @@ function backup() { R_SNAPSHOTS=( $(${R_RMOD} zfs list -rt snapshot -d1 -Ho name -S creation ${SAVETO}/$( basename ${DATASET}) 2>/dev/null) ) check_dataset ${SAVETO}/$( basename ${DATASET}) && R_USED_BEFORE=$(snapuse ${SAVETO}/$( basename ${DATASET})) - if [ ${MODE:-backup} == "backup" ] + if [ $MODE == "backup" ] then # determine current timestamp DATE=$(date +%Y-%m-%d-%H%M) @@ -127,7 +127,7 @@ function backup() { unset SNAPMODIFIER R_SNAPMODIFIER fi - if [ ${MODE:-backup} == "backup" ] + if [ $MODE == "backup" ] then # send backup zfs send -Rcv${RAW_MOD}${SNAPMODIFIER} ${NEWSNAP} | ${RMOD:-$R_RMOD} zfs recv -Feu${RESUME_MOD}v ${SAVETO} 2>&1 >> ${LOGFILE} @@ -202,7 +202,7 @@ function backup() { #### BEGIN LOGIC #### -while getopts hf:m:s OPTION +while getopts hf:m: OPTION do case "$OPTION" in f) @@ -215,11 +215,6 @@ while getopts hf:m:s OPTION RECIPIENT="$OPTARG" ;; - s) - # sync mode | this could also be a per-target setting to mitigate the need to call multiple jobs - MODE="sync" - ;; - h|\?) # display help usage @@ -296,7 +291,7 @@ LOGDIR="/var/log" # determine session logfile LOGFILE="${LOGDIR:-/tmp}/${ME}_${RUNDATE}.txt" -while read -u 4 DATASET SAVETO KEEP ENABLED +while read -u 4 DATASET SAVETO KEEP MODE ENABLED # alternate file descriptor in use because SSH might be involved and we can not pass '-n' to it because we need stdin for 'zfs recv' do let COUNTER++