diff options
| author | Laurent Cozic <laurent@cozic.net> | 2016-09-10 11:32:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-10 11:32:11 +0100 |
| commit | b9d359f797d67749a180b7fdae7d7a828725cc58 (patch) | |
| tree | 120bef1b0dabe5db14817e5a2a655fcdb54067f1 | |
| parent | d680039e5fd9a12e9fbf98bc1e020f3005c9f5d6 (diff) | |
Update rsync_tmbackup.sh
Allow getting and setting rsync options
| -rwxr-xr-x | rsync_tmbackup.sh | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index d325b0b..9c2381e 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -32,11 +32,13 @@ trap 'fn_terminate_script' SIGINT # Small utility functions for reducing code duplication # ----------------------------------------------------------------------------- fn_display_usage() { - fn_log_info "Usage : $(basename $0) [args] <source> <[user@host:]destination> [exclude-pattern-file]" - fn_log_info "" - fn_log_info "Options:" - fn_log_info "-p, --port SSH port" - fn_log_info "-h, --help Display this help message" + echo "Usage: $(basename $0) [OPTION]... <SOURCE> <[USER@HOST:]DESTINATION> [exclude-pattern-file]" + echo "" + echo "Options" + echo " -p, --port SSH port." + echo " -h, --help Display this help message." + echo " --rsync-get-flags Display the default rsync flags that are used for backup." + echo " --rsync-set-flags Set the rsync flags that are going to be used for backup." } fn_parse_date() { @@ -122,6 +124,8 @@ SRC_FOLDER="" DEST_FOLDER="" EXCLUSION_FILE="" +RSYNC_FLAGS="--compress --numeric-ids --links --hard-links --one-file-system --archive --itemize-changes --verbose" + while :; do case $1 in -h|-\?|--help) @@ -132,6 +136,15 @@ while :; do shift SSH_PORT=$1 ;; + --rsync-get-flags) + shift + echo $RSYNC_FLAGS + exit + ;; + --rsync-set-flags) + shift + RSYNC_FLAGS="$1" + ;; --) shift SRC_FOLDER="${1%/}" @@ -321,14 +334,7 @@ while : ; do if [ -n "$SSH_CMD" ]; then CMD="$CMD -e 'ssh -p $SSH_PORT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'" fi - CMD="$CMD --compress" - CMD="$CMD --numeric-ids" - CMD="$CMD --links" - CMD="$CMD --hard-links" - CMD="$CMD --one-file-system" - CMD="$CMD --archive" - CMD="$CMD --itemize-changes" - CMD="$CMD --verbose" + CMD="$CMD $RSYNC_FLAGS" CMD="$CMD --log-file '$LOG_FILE'" if [ -n "$EXCLUSION_FILE" ]; then # We've already checked that $EXCLUSION_FILE doesn't contain a single quote |
