From 7760083f09068e99f157d4f9cd40a1dddb8780c2 Mon Sep 17 00:00:00 2001 From: Nathaniel Landau Date: Sat, 21 Mar 2015 20:51:03 -0400 Subject: [PATCH] v2.1.0 - support for extended RSYNC configurations --- syncScripts/SyncTemplate.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/syncScripts/SyncTemplate.sh b/syncScripts/SyncTemplate.sh index 2737c14..f0f550f 100755 --- a/syncScripts/SyncTemplate.sh +++ b/syncScripts/SyncTemplate.sh @@ -4,7 +4,7 @@ # ################################################## # My Generic sync script. # -version="2.0.0" # Sets version variable +version="2.1.0" # Sets version variable # scriptTemplateVersion="1.1.1" # Version of scriptTemplate.sh that this script is based on # v.1.1.0 - Added 'debug' option @@ -41,6 +41,7 @@ scriptTemplateVersion="1.1.1" # Version of scriptTemplate.sh that this script is # * 2015-03-10 - v1.1.1 - Updated script template version # - Removed $logFile from config. Default is now '~/library/logs/' # * 2015-03-15 - v2.0.0 - Added support for encrypted config files. +# * 2015-03-21 - v2.1.0 - Added support for extended RSYNC configurations. # # ################################################## @@ -239,10 +240,17 @@ UNISONPROFILE="" # --------------------------- # If you are using rsync, complete this section -# EXCLUDE is a text file that contains all the rsync excludes. -# Anything listed within this file will be ignored during sync. +# EXCLUDE sets rsync to exclude files from syncing based on a pattern. +# Defaults to null. +# If needed, add individual excludes in the format of "--exclude file1.txt --exclude file2.txt". EXCLUDE="" +# EXCLUDELIST is a text file that contains all the rsync excludes. +# Anything listed within this file will be ignored during sync. +# Default is null. +# Set value to "--exclude-from=/some/file/location" if needed +EXCLUDELIST="" + # DELETE sets the variable to delete files in the target directory that are deleted from # the source directory. Defaults to equal "--delete" which sets that flag. Set to null # to ensure all files on the target remain when deleted from the source. @@ -369,13 +377,20 @@ function testSources() { } function runRsync() { + # Populate logfile variable if "printlog=1" + if [ "printLog" = 1 ]; then + RSYNCLOG="--log-file=${logFile}" + else + RSYNCLOG="" + fi + if [ "${METHOD}" = "rsync" ]; then if [ "${debug}" = "1" ]; then - verbose "/usr/bin/rsync -vahh${DRYRUN}${COMPRESS} --progress --force ${DELETE} --exclude-from=${EXCLUDE} ${SOURCEDIRECTORY} ${TARGETDIRECTORY} --log-file=${logFile}" + verbose "/usr/bin/rsync -vahh${DRYRUN}${COMPRESS} --progress --force ${DELETE} ${EXCLUDE} ${EXCLUDELIST} ${SOURCEDIRECTORY} ${TARGETDIRECTORY} ${RSYNCLOG}" else notice "Commencing rsync" - /usr/bin/rsync -vahh"${DRYRUN}""${COMPRESS}" --progress --force ${DELETE} --exclude-from="${EXCLUDE}" "${SOURCEDIRECTORY}" "${TARGETDIRECTORY}" --log-file="${logFile}" - verbose "/usr/bin/rsync -vahh${DRYRUN}${COMPRESS} --progress --force ${DELETE} --exclude-from=${EXCLUDE} ${SOURCEDIRECTORY} ${TARGETDIRECTORY} --log-file=${logFile}" + /usr/bin/rsync -vahh"${DRYRUN}""${COMPRESS}" --progress --force "${DELETE}" "${EXCLUDE}" "${EXCLUDELIST}" "${SOURCEDIRECTORY}" "${TARGETDIRECTORY}" "${RSYNCLOG}" + verbose "/usr/bin/rsync -vahh${DRYRUN}${COMPRESS} --progress --force ${DELETE} ${EXCLUDE} ${EXCLUDELIST} ${SOURCEDIRECTORY} ${TARGETDIRECTORY} ${RSYNCLOG}" fi fi }