Add dry-run argument (-d)

dev
hk 2017-06-09 13:40:06 +02:00
parent b2da1e1da5
commit a1b15281e9
1 changed files with 15 additions and 1 deletions

View File

@ -9,6 +9,8 @@ Usage: $(basename "${BASH_SOURCE[0]}") [OPTIONS] MODE
OPTIONS
-c CONFIG_FILE
-d
Run borg commands with dry-run where applicable
-V
Print version and exit.
@ -50,6 +52,10 @@ borg_backup () {
)
fi
if ${DRY_RUN}; then
BORG_BACKUP_ARGS+=( --dry-run )
fi
${BORG} create \
"${BORG_BACKUP_ARGS[@]}" \
"${BORG_REPO}"::"{hostname}-$(date -u +'%Y%m%dT%H%M%SZ')" \
@ -66,6 +72,10 @@ borg_prune () {
)
fi
if ${DRY_RUN}; then
BORG_PRUNE_ARGS+=( --dry-run )
fi
${BORG} prune \
"${BORG_PRUNE_ARGS[@]}" \
--prefix "{hostname}-" \
@ -189,6 +199,7 @@ exit_clean () {
# Default parameters
CONFIG="/etc/borgwrapper/config.sh"
DRY_RUN=false
BORG="/usr/bin/borg"
LOCKDIR="/run/lock/borgwrapper"
PRE_BACKUP_CMD=()
@ -196,11 +207,14 @@ POST_BACKUP_CMD=()
POST_VERIFY_CMD=()
BWLIMIT=0
while getopts ":c:V" OPT; do
while getopts ":c:dV" OPT; do
case ${OPT} in
c)
CONFIG="${OPTARG}"
;;
d)
DRY_RUN=true
;;
V)
print_version
exit 0