mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-09 12:22:40 +01:00
restic: quote string and path values in command options
Make this consistent with the borg handler. Allows users to use paths that include spaces in them and prevents shell globbing when the restic command is called. According to the restic docs, if glob paths are needed, they should be read from a file (--files-from).
This commit is contained in:
parent
a8df514531
commit
f71d6882c6
@ -279,32 +279,33 @@ if [ "$run_backup" == "yes" ]; then
|
||||
getconf time
|
||||
getconf with_atime
|
||||
|
||||
# prevent bash from expanding glob
|
||||
set -f
|
||||
set -o noglob
|
||||
SAVEIFS=$IFS
|
||||
IFS=$(echo -en "\n\b")
|
||||
|
||||
[ -z "$include" ] && [ -z "$files_from" ] && \
|
||||
fatal "No files or directories specified for backup."
|
||||
|
||||
[ -n "$include" ] && \
|
||||
cmd_options+="$(for i in $include; do echo "$i "; done)"
|
||||
cmd_options+="$(for i in $include; do echo "'$i' "; done)"
|
||||
|
||||
[ -n "$files_from" ] && \
|
||||
cmd_options+="$(for i in $files_from; do echo "--files-from $i "; done)"
|
||||
cmd_options+="$(for i in $files_from; do echo "--files-from '$i' "; done)"
|
||||
|
||||
[ -d "$repository" ] && \
|
||||
cmd_options+="--exclude $repository "
|
||||
|
||||
[ -n "$exclude" ] && \
|
||||
cmd_options+="$(for i in $exclude; do echo "--exclude $i "; done)"
|
||||
cmd_options+="$(for i in $exclude; do echo "--exclude '$i' "; done)"
|
||||
|
||||
[ "$exclude_caches" == "yes" ] && \
|
||||
cmd_options+="--exclude-caches "
|
||||
|
||||
[ -n "$exclude_file" ] && \
|
||||
cmd_options+="$(for i in $exclude_file; do echo "--exclude-file $i "; done)"
|
||||
cmd_options+="$(for i in $exclude_file; do echo "--exclude-file '$i' "; done)"
|
||||
|
||||
[ -n "$exclude_if_present" ] && \
|
||||
cmd_options+="$(for i in $exclude_if_present; do echo "--exclude-if-present $i "; done)"
|
||||
cmd_options+="$(for i in $exclude_if_present; do echo "--exclude-if-present '$i' "; done)"
|
||||
|
||||
[ "$force" == "yes" ] && \
|
||||
cmd_options+="--force "
|
||||
@ -319,7 +320,7 @@ if [ "$run_backup" == "yes" ]; then
|
||||
cmd_options+="--parent $parent "
|
||||
|
||||
[ -n "$tag" ] && \
|
||||
cmd_options+="$(for i in $tag; do echo "--tag=$i "; done)"
|
||||
cmd_options+="$(for i in $tag; do echo "--tag='$i' "; done)"
|
||||
|
||||
[ -n "$time" ] && \
|
||||
cmd_options+="--time $time "
|
||||
@ -327,6 +328,9 @@ if [ "$run_backup" == "yes" ]; then
|
||||
[ "$with_atime" == "yes" ] && \
|
||||
cmd_options+="--with_atime "
|
||||
|
||||
IFS=$SAVEIFS
|
||||
set +o noglob
|
||||
|
||||
# format command
|
||||
cmd="restic backup"
|
||||
execstr="${precmd}${cmd} ${cmd_global_options//$'\n'}${cmd_options//$'\n'}"
|
||||
@ -351,9 +355,6 @@ if [ "$run_backup" == "yes" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# set bash orginal globbing behavior
|
||||
set +f
|
||||
|
||||
debug "Unsetting variables"
|
||||
unset cmd_options
|
||||
unset execstr
|
||||
@ -384,6 +385,10 @@ if [[ "$run_forget" == "yes" ]]; then
|
||||
getconf dry_run
|
||||
getconf prune
|
||||
|
||||
set -o noglob
|
||||
SAVEIFS=$IFS
|
||||
IFS=$(echo -en "\n\b")
|
||||
|
||||
[ -n "$keep_last" ] && \
|
||||
cmd_options+="--keep-last $keep_last "
|
||||
|
||||
@ -429,6 +434,9 @@ if [[ "$run_forget" == "yes" ]]; then
|
||||
[ -n "$prune" ] && \
|
||||
cmd_options+="--prune "
|
||||
|
||||
IFS=$SAVEIFS
|
||||
set +o noglob
|
||||
|
||||
# format command
|
||||
cmd="restic forget"
|
||||
execstr="${precmd}${cmd} ${cmd_global_options//$'\n'}${cmd_options//$'\n'}"
|
||||
|
Loading…
Reference in New Issue
Block a user