-u option now mounts usmb partition beforehand, then umounts after.
This commit is contained in:
parent
3708c64d1f
commit
efe2889766
26
bare.sh
26
bare.sh
|
@ -9,6 +9,7 @@ LOGFILE=/var/log/backup.log
|
|||
RESTIC=/usr/local/bin/restic
|
||||
RCLONE=/usr/local/bin/rclone
|
||||
RSYNC=/usr/local/bin/rsync
|
||||
USMB=/usr/local/bin/usmb
|
||||
|
||||
DATAPATH_PREFIX="/DataVolume/shares"
|
||||
|
||||
|
@ -22,7 +23,7 @@ LOG=/dev/stdout
|
|||
DATE=/bin/date
|
||||
DOALL=0
|
||||
REPOSTOBACKUP=""
|
||||
UMOUNTAFTER=0
|
||||
USEUSMB=0
|
||||
|
||||
function log() {
|
||||
local now
|
||||
|
@ -136,7 +137,7 @@ while getopts "$ARGS" i; do
|
|||
TESTMODE=1
|
||||
;;
|
||||
u)
|
||||
UMOUNTAFTER=1
|
||||
USEUSMB=1
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid argument: $i";
|
||||
|
@ -233,12 +234,27 @@ fi
|
|||
# Validate repos
|
||||
for f in $REPOSTOBACKUP; do
|
||||
DATAPATH=$(getdatapath $f)
|
||||
USMBNAME=`echo "${DATAPATH}" | sed -e "s,${DATAPATH_PREFIX}/\(.*\)/.*,\1,"`
|
||||
|
||||
if [[ -z $DATAPATH ]]; then
|
||||
log "can't find matching repo for $f - make sure it is listed in ${RCFILE}"
|
||||
log "can't find matching repo for $f - make sure it is listed in ${REPOFILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $USEUSMB -eq 1 ]]; then
|
||||
mount | grep -q ${DATAPATH}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
# try mounting it.
|
||||
${USMB} ${USMBNAME} >/dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
log "Mount usmb volume '$USMBNAME': success"
|
||||
else
|
||||
log "Mount usmb volume '$USMBNAME': FAILED"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [[ -e ${DATAPATH} ]]; then
|
||||
log "Error: ${DATAPATH} doesn't exist"
|
||||
exit 1
|
||||
|
@ -246,7 +262,6 @@ 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
|
||||
|
@ -442,8 +457,7 @@ for f in $REPOSTOBACKUP; do
|
|||
fi
|
||||
|
||||
if [[ $rv -eq 0 ]]; then
|
||||
if [[ UMOUNTAFTER -eq 1 ]]; then
|
||||
USMBNAME=`echo "${DATAPATH}" | sed -e 's,${DATAPATH_PREFIX}/\(.*\)/.*,\1,'`
|
||||
if [[ $USEUSMB -eq 1 ]]; then
|
||||
log "Unmounting usmb volume '$USMBNAME'"
|
||||
usmb -u $USMBNAME
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue