shell判断是否挂载


以赛事平台通过rsync将本地数据库备份同步到本地挂载得nas目录为例:
#!/bin/bash
mountpoint -q /nasbak
mflag=$?
if [ $mflag != 0 ];then
echo $(date +"%Y%m%d")"nas未挂载,现在执行挂载" >> /home/mount_log/mountpoint-$(date +"%Y%m%d").log
mount -t nfs -o nolock,nfsvers=3 192.168.100.100:/volume1/ssptbak /nasbak
mountpoint -q /nasbak
mflag=$?
if [ $mflag != 0 ];then
echo $(date +"%Y%m%d")"nas挂载失败" >> /home/mount_log/mount-$(date +"%Y%m%d").log
else
rsync -avu --progress --delete /home/backup/ /nasbak/dbbak/
fi
else
rsync -avu --progress --delete /home/backup/ /nasbak/dbbak/
fi
exit 0