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