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