diff --git a/bare.sh b/bare.sh index a4ddc3f..a538ff0 100755 --- a/bare.sh +++ b/bare.sh @@ -57,11 +57,12 @@ function usage-repo() { echo " rsync Backup using rsync (defualt repo is \$DEF_RSYNC_USER@\$DEF_RSYNC_SERVER:\$DEF_RSYNC_DIR/)" echo "" echo "Pre-backup commands to access local files:" - echo " nfs Mount \$DEF_NFS_SERVER:\$DEF_NFS_SERVER_BASE/ to " - echo " before running. Sharename determined by stripping \$NFS_PREFIX" - echo " from start of repo path." - echo " usmb Run 'usmb reponame' to mount \$USMB_PREFIX/ before running." - echo " Sharename determined by stripping \$NFS_PREFIX from start of ." + echo " nfs Mount \$DEF_NFS_SERVER:\$DEF_NFS_SERVER_BASE/ to " + echo " before running. Sharename determined by stripping \$NFS_PREFIX" + echo " from start of repo path." + echo " usmb Run 'usmb reponame' to mount \$USMB_PREFIX/ before running." + echo " Sharename determined by stripping \$NFS_PREFIX from start of ." + echo " localmount Run 'mount reponame' to mount before running." } function usage-rc() { echo " export B2_ACCOUNT_ID=xxx # Backblaze B2 credentials" @@ -252,6 +253,9 @@ function do_umount() { elif [[ $USENFS -eq 1 ]]; then log "Unmounting nfs volume '$NFSPATH' from $DATAPATH" umount $DATAPATH + elif [[ $USELOCALMOUNT -eq 1 ]]; then + log "Unmounting dir $DATAPATH" + umount $DATAPATH fi } @@ -439,6 +443,17 @@ for f in $REPOSTOBACKUP; do NFSNAME="" USENFS=0 fi + checktag "$f" localmount + if [[ $? -eq 0 ]]; then + grep -q $DTAPATH /etc/fstab + if [[ $? -ne 0 ]]; then + log "Error: repo '$REPO' has localmount tag but $DATAPATH not in fstab." + continue + fi + USELOCALMOUNT=1 + else + USELOCALMOUNT=0 + fi if [[ -z $DATAPATH ]]; then log "can't find matching repo for $f - make sure it is listed in ${REPOFILE}" @@ -479,6 +494,19 @@ for f in $REPOSTOBACKUP; do continue fi fi + elif [[ $USELOCALMOUNT -eq 1 ]]; then + mount | grep -q ${DATAPATH} + if [[ $? -ne 0 ]]; then + # try mounting it. + mkdir -p $DATAPATH + mount ${DATAPATH} >/dev/null + if [[ $? -eq 0 ]]; then + log "Mount $DATAPATH: success" + else + log "Mount $DATAPATH: FAILED" + continue + fi + fi fi if ! [[ -e ${DATAPATH} ]]; then @@ -546,6 +574,13 @@ for f in $REPOSTOBACKUP; do NFSNAME="" USENFS=0 fi + + checktag "$f" localmount + if [[ $? -eq 0 ]]; then + USELOCALMOUNT=1 + else + USELOCALMOUNT=0 + fi export REPO_PATH=`getrepopath "$f"`