Added -u option ro tun usmb umount when done
This commit is contained in:
parent
e6cd761452
commit
3708c64d1f
19
bare.sh
19
bare.sh
|
@ -10,6 +10,7 @@ RESTIC=/usr/local/bin/restic
|
|||
RCLONE=/usr/local/bin/rclone
|
||||
RSYNC=/usr/local/bin/rsync
|
||||
|
||||
DATAPATH_PREFIX="/DataVolume/shares"
|
||||
|
||||
#RCLONEOPTS="--cache-chunk-no-memory --buffer-size=10M --progress"
|
||||
RCLONEOPTS="--progress --buffer-size 10M --cache-chunk-no-memory"
|
||||
|
@ -21,6 +22,7 @@ LOG=/dev/stdout
|
|||
DATE=/bin/date
|
||||
DOALL=0
|
||||
REPOSTOBACKUP=""
|
||||
UMOUNTAFTER=0
|
||||
|
||||
function log() {
|
||||
local now
|
||||
|
@ -57,6 +59,7 @@ function usage() {
|
|||
echo " -x num Use 'num' simultaneous connections (default: 20)"
|
||||
echo " -c Cron mode - log to ${LOGFILE}"
|
||||
echo " -t Test mode - dump what would be done then exit."
|
||||
echo " -u Unmount (via usmb) local dir when done."
|
||||
echo ""
|
||||
echo "Valid commands are:"
|
||||
echo " $VALIDCOMMANDS"
|
||||
|
@ -108,7 +111,7 @@ function checktag() { # return 0 if tag matches
|
|||
}
|
||||
|
||||
# Handle args
|
||||
ARGS="acdhs:tu:x:"
|
||||
ARGS="acdhs:tux:"
|
||||
|
||||
while getopts "$ARGS" i; do
|
||||
case "$i" in
|
||||
|
@ -132,6 +135,9 @@ while getopts "$ARGS" i; do
|
|||
t)
|
||||
TESTMODE=1
|
||||
;;
|
||||
u)
|
||||
UMOUNTAFTER=1
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid argument: $i";
|
||||
usage;
|
||||
|
@ -240,6 +246,7 @@ for f in $REPOSTOBACKUP; do
|
|||
|
||||
count=`ls ${DATAPATH} | wc -l`
|
||||
if [ $count -le 2 ]; then
|
||||
# TODO: try mounting it.
|
||||
log "Error: ${DATAPATH} exists but appears to be empty"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -434,8 +441,14 @@ for f in $REPOSTOBACKUP; do
|
|||
fi
|
||||
fi
|
||||
|
||||
if [[ $rv -ne 0 ]]; then
|
||||
echo "Error: command failed."
|
||||
if [[ $rv -eq 0 ]]; then
|
||||
if [[ UMOUNTAFTER -eq 1 ]]; then
|
||||
USMBNAME=`echo "${DATAPATH}" | sed -e 's,${DATAPATH_PREFIX}/\(.*\)/.*,\1,'`
|
||||
log "Unmounting usmb volume '$USMBNAME'"
|
||||
usmb -u $USMBNAME
|
||||
fi
|
||||
else
|
||||
log "Error: '$CMD' on repo '$REPO' failed"
|
||||
fi
|
||||
|
||||
log "Finished '$CMD' on repo '$REPO'"
|
||||
|
|
Loading…
Reference in New Issue