mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-09 13:43:46 -05:00
Fixed rsync variables
This commit is contained in:
@@ -83,6 +83,7 @@ force=0
|
|||||||
strict=0
|
strict=0
|
||||||
debug=0
|
debug=0
|
||||||
editConfig=0
|
editConfig=0
|
||||||
|
mountTest=0
|
||||||
|
|
||||||
# Set Temp Directory
|
# Set Temp Directory
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
@@ -276,7 +277,6 @@ EOL
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function editConfiguration() {
|
function editConfiguration() {
|
||||||
# If the '--config' is set to true, we create an editable config file for re-encryption
|
# If the '--config' is set to true, we create an editable config file for re-encryption
|
||||||
if [ "${editConfig}" == "1" ]; then
|
if [ "${editConfig}" == "1" ]; then
|
||||||
@@ -333,6 +333,15 @@ function moutDrives() {
|
|||||||
else
|
else
|
||||||
notice "${REMOTEVOLUME} was already mounted."
|
notice "${REMOTEVOLUME} was already mounted."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#Allow for debugging with only the mount function
|
||||||
|
if [ ${mountTest} = 1 ]; then
|
||||||
|
seek_confirmation "Are you ready to unmount the drive"
|
||||||
|
if is_confirmed; then
|
||||||
|
unmountDrives
|
||||||
|
safeExit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,20 +387,14 @@ function testSources() {
|
|||||||
|
|
||||||
function runRsync() {
|
function runRsync() {
|
||||||
# Populate logfile variable if "printlog=1"
|
# Populate logfile variable if "printlog=1"
|
||||||
if [ "printLog" = 1 ]; then
|
if [ "${printLog}" = 1 ]; then
|
||||||
RSYNCLOG="--log-file=${logFile}"
|
RSYNCLOG="--log-file=${logFile}"
|
||||||
else
|
else
|
||||||
RSYNCLOG=""
|
RSYNCLOG=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${METHOD}" = "rsync" ]; then
|
if [ "${METHOD}" = "rsync" ]; then
|
||||||
if [ "${debug}" = "1" ]; then
|
|
||||||
verbose "/usr/bin/rsync -vahh${DRYRUN}${COMPRESS} --progress --force ${DELETE} ${EXCLUDE} ${EXCLUDELIST} ${SOURCEDIRECTORY} ${TARGETDIRECTORY} ${RSYNCLOG}"
|
|
||||||
else
|
|
||||||
notice "Commencing rsync"
|
notice "Commencing rsync"
|
||||||
/usr/bin/rsync -vahh"${DRYRUN}""${COMPRESS}" --progress --force "${DELETE}" "${EXCLUDE}" "${EXCLUDELIST}" "${SOURCEDIRECTORY}" "${TARGETDIRECTORY}" "${RSYNCLOG}"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,6 +513,7 @@ usage() {
|
|||||||
-l, --log Print log to file
|
-l, --log Print log to file
|
||||||
-n, --dryrun Dry run. If using rsync, will run everything
|
-n, --dryrun Dry run. If using rsync, will run everything
|
||||||
without making any changes
|
without making any changes
|
||||||
|
-m, --mounttest Will run the mount/unmount drive portion of the script and bypass all syncing.
|
||||||
-p, --password Prompts for the password which decrypts the configuration file
|
-p, --password Prompts for the password which decrypts the configuration file
|
||||||
-q, --quiet Quiet (no output)
|
-q, --quiet Quiet (no output)
|
||||||
-s, --strict Exit script with null variables. 'set -o nounset'
|
-s, --strict Exit script with null variables. 'set -o nounset'
|
||||||
@@ -574,6 +578,7 @@ while [[ $1 = -?* ]]; do
|
|||||||
-s|--strict) strict=1;;
|
-s|--strict) strict=1;;
|
||||||
-f|--force) force=1 ;;
|
-f|--force) force=1 ;;
|
||||||
-n|--dryrun) DRYRUN=n ;;
|
-n|--dryrun) DRYRUN=n ;;
|
||||||
|
-m|--mounttest) mountTest=1 ;;
|
||||||
-z|--compress) COMPRESS=z ;;
|
-z|--compress) COMPRESS=z ;;
|
||||||
--endopts) shift; break ;;
|
--endopts) shift; break ;;
|
||||||
*) warning "invalid option: $1.\n"; usage >&2; safeExit ;;
|
*) warning "invalid option: $1.\n"; usage >&2; safeExit ;;
|
||||||
@@ -607,6 +612,11 @@ if [ "${strict}" == "1" ]; then
|
|||||||
set -o nounset
|
set -o nounset
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run in debug mode, if set
|
||||||
|
if [ "${debug}" == "1" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
# Bash will remember & return the highest exitcode in a chain of pipes.
|
# Bash will remember & return the highest exitcode in a chain of pipes.
|
||||||
# This way you can catch the error in case mysqldump fails in `mysqldump |gzip`
|
# This way you can catch the error in case mysqldump fails in `mysqldump |gzip`
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|||||||
Reference in New Issue
Block a user