Added: --progress option Fixed: --verbose option overwriting --dry-run, missing space before SSH_OPTIONS
This commit is contained in:
parent
6bb9f1189b
commit
6e179b71e5
|
@ -28,6 +28,7 @@ _SKIP_HOME_DIRS=false
|
||||||
_FORCED_LOG_FILE=""
|
_FORCED_LOG_FILE=""
|
||||||
_QUIET_MODE=false
|
_QUIET_MODE=false
|
||||||
_VERBOSE_MODE=false
|
_VERBOSE_MODE=false
|
||||||
|
_SHOW_PROGRESS=false # Option to display file transfer progress
|
||||||
_DRY_RUN=false
|
_DRY_RUN=false
|
||||||
_FORCE_RUN=false
|
_FORCE_RUN=false
|
||||||
_ERROR_COUNT=0
|
_ERROR_COUNT=0
|
||||||
|
@ -81,6 +82,7 @@ Options:
|
||||||
-q, --quiet Don't print any error messages or warnings to the
|
-q, --quiet Don't print any error messages or warnings to the
|
||||||
screen (only write to log file)
|
screen (only write to log file)
|
||||||
-v, --verbose Print all messages of the current debug level
|
-v, --verbose Print all messages of the current debug level
|
||||||
|
-p, --progress Print file transfer information to the terminal
|
||||||
-h, --help Print this help and exit
|
-h, --help Print this help and exit
|
||||||
HELP
|
HELP
|
||||||
}
|
}
|
||||||
|
@ -228,19 +230,21 @@ perform_backup() {
|
||||||
local msg
|
local msg
|
||||||
local backup_cmd
|
local backup_cmd
|
||||||
local ssh_cmd
|
local ssh_cmd
|
||||||
local rsync_opts
|
local rsync_opts="${RSNC_OPTIONS}"
|
||||||
local exit_code
|
local exit_code
|
||||||
local tee_device="/dev/null"
|
local tee_device="/dev/tty"
|
||||||
|
|
||||||
if $_DRY_RUN; then
|
if $_DRY_RUN; then
|
||||||
rsync_opts="${RSYNC_OPTIONS} --dry-run"
|
rsync_opts+=" --dry-run"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $_VERBOSE_MODE; then
|
if $_SHOW_PROGRESS; then
|
||||||
tee_device="/dev/tty"
|
rsync_opts+=" --progress" # append to rsync_opts: preserves other options (e.g. --dry-run)
|
||||||
rsync_opts="${RSYNC_OPTIONS} --verbose"
|
elif $_VERBOSE_MODE; then # --progress implies --verbose
|
||||||
|
rsync_opts+=" --verbose"
|
||||||
else
|
else
|
||||||
rsync_opts="${RSYNC_OPTIONS} --quiet"
|
tee_device="/dev/null"
|
||||||
|
rsync_opts+=" --quiet"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${username}" == "" ]; then
|
if [ "${username}" == "" ]; then
|
||||||
|
@ -257,7 +261,7 @@ perform_backup() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${SSH_OPTIONS}" != "" ]; then
|
if [ "${SSH_OPTIONS}" != "" ]; then
|
||||||
ssh_cmd="ssh"$(echo -n "${SSH_OPTIONS}" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
|
ssh_cmd="ssh "$(echo -n "${SSH_OPTIONS}" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g') # added missing space
|
||||||
else
|
else
|
||||||
ssh_cmd="ssh"
|
ssh_cmd="ssh"
|
||||||
fi
|
fi
|
||||||
|
@ -382,8 +386,8 @@ parse_cmd_args() {
|
||||||
|
|
||||||
args=$(getopt \
|
args=$(getopt \
|
||||||
-s sh \
|
-s sh \
|
||||||
-o "r:o:nsi:l:fqvh" \
|
-o "r:o:nsi:l:fqvph" \
|
||||||
-l "remote-host:,remote-user:,push-module:,ssh-options:,rsync-options:,dry-run,no-home-dirs,include-from:,log-level:,log-file:,force-run,quiet,verbose,help" \
|
-l "remote-host:,remote-user:,push-module:,ssh-options:,rsync-options:,dry-run,no-home-dirs,include-from:,log-level:,log-file:,force-run,quiet,verbose,progress,help" \
|
||||||
-n "${name}" \
|
-n "${name}" \
|
||||||
-- "${@}")
|
-- "${@}")
|
||||||
|
|
||||||
|
@ -439,6 +443,9 @@ parse_cmd_args() {
|
||||||
"-v"|"--verbose")
|
"-v"|"--verbose")
|
||||||
! $_QUIET_MODE && _VERBOSE_MODE=true
|
! $_QUIET_MODE && _VERBOSE_MODE=true
|
||||||
shift ;;
|
shift ;;
|
||||||
|
"-p"|"--progress")
|
||||||
|
! $_QUIET_MODE && _SHOW_PROGRESS=true
|
||||||
|
shift ;;
|
||||||
"-h"|"--help")
|
"-h"|"--help")
|
||||||
print_help
|
print_help
|
||||||
exit ;;
|
exit ;;
|
||||||
|
|
Loading…
Reference in New Issue