Add localmount tag to mount dir via fstab before action.
This commit is contained in:
parent
b50a3be2c4
commit
1f48477940
45
bare.sh
45
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/<reponame>)"
|
echo " rsync Backup using rsync (defualt repo is \$DEF_RSYNC_USER@\$DEF_RSYNC_SERVER:\$DEF_RSYNC_DIR/<reponame>)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Pre-backup commands to access local files:"
|
echo "Pre-backup commands to access local files:"
|
||||||
echo " nfs Mount \$DEF_NFS_SERVER:\$DEF_NFS_SERVER_BASE/<sharename> to <repopath>"
|
echo " nfs Mount \$DEF_NFS_SERVER:\$DEF_NFS_SERVER_BASE/<sharename> to <repopath>"
|
||||||
echo " before running. Sharename determined by stripping \$NFS_PREFIX"
|
echo " before running. Sharename determined by stripping \$NFS_PREFIX"
|
||||||
echo " from start of repo path."
|
echo " from start of repo path."
|
||||||
echo " usmb Run 'usmb reponame' to mount \$USMB_PREFIX/<sharename> before running."
|
echo " usmb Run 'usmb reponame' to mount \$USMB_PREFIX/<sharename> before running."
|
||||||
echo " Sharename determined by stripping \$NFS_PREFIX from start of <repopath>."
|
echo " Sharename determined by stripping \$NFS_PREFIX from start of <repopath>."
|
||||||
|
echo " localmount Run 'mount reponame' to mount <path_to_files> before running."
|
||||||
}
|
}
|
||||||
function usage-rc() {
|
function usage-rc() {
|
||||||
echo " export B2_ACCOUNT_ID=xxx # Backblaze B2 credentials"
|
echo " export B2_ACCOUNT_ID=xxx # Backblaze B2 credentials"
|
||||||
|
@ -252,6 +253,9 @@ function do_umount() {
|
||||||
elif [[ $USENFS -eq 1 ]]; then
|
elif [[ $USENFS -eq 1 ]]; then
|
||||||
log "Unmounting nfs volume '$NFSPATH' from $DATAPATH"
|
log "Unmounting nfs volume '$NFSPATH' from $DATAPATH"
|
||||||
umount $DATAPATH
|
umount $DATAPATH
|
||||||
|
elif [[ $USELOCALMOUNT -eq 1 ]]; then
|
||||||
|
log "Unmounting dir $DATAPATH"
|
||||||
|
umount $DATAPATH
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,6 +443,17 @@ for f in $REPOSTOBACKUP; do
|
||||||
NFSNAME=""
|
NFSNAME=""
|
||||||
USENFS=0
|
USENFS=0
|
||||||
fi
|
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
|
if [[ -z $DATAPATH ]]; then
|
||||||
log "can't find matching repo for $f - make sure it is listed in ${REPOFILE}"
|
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
|
continue
|
||||||
fi
|
fi
|
||||||
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
|
fi
|
||||||
|
|
||||||
if ! [[ -e ${DATAPATH} ]]; then
|
if ! [[ -e ${DATAPATH} ]]; then
|
||||||
|
@ -546,6 +574,13 @@ for f in $REPOSTOBACKUP; do
|
||||||
NFSNAME=""
|
NFSNAME=""
|
||||||
USENFS=0
|
USENFS=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
checktag "$f" localmount
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
USELOCALMOUNT=1
|
||||||
|
else
|
||||||
|
USELOCALMOUNT=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
export REPO_PATH=`getrepopath "$f"`
|
export REPO_PATH=`getrepopath "$f"`
|
||||||
|
|
Loading…
Reference in New Issue