bash script help to check nfs mount exists [rsnapshot]
0
votes
1
answer
1769
views
I have two linux servers; server two is a backup to server one where server two is NFS mounted to server one.
I use
rsnapshot
on server one to copy from /data/
to the **nfs mounted** folder /bkup
from server two.
Problem is if the nfs /bkup
mount isn't there, rsnapshot will copy /data {20tb) onto the root partition {1tb}.
Instead of cron'ing my one call to launch rsnapshot I would like to call a backup script that first checks on everything before calling rsnaphot to prevent that scenario. I do not think rsnapshot's no_create_root
is relevant because the /bkup
folder will always exist. Can the following happen in a bash script? *i'm hoping someone fluent in bash can type it up in 2 minutes? my bash writing is horrible.*
if ( showmount -e server_two responds with "/bkup server_two" )
{
if ( check if /bkup is nfs mounted == true )
{
/usr/bin/rsnapshot daily
}
else
{
mount /bkup
if ( check if /bkup is nfs mounted === true )
{
/usr/bin/rsnapshot daily
}
}
}
right now I have this to work where/when my nfs bkup mount is good on server_one
mount | grep bkup
server_two:/bkup on /bkup type nfs4
(rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.2,local_lock=none,addr=192.168.1.1)
df -h | grep bkup
server_two:/bkup 15T 3.0T 12T 21% /bkup
showmount -e server_two
Export list for server_two:
/bkup server_one
Asked by ron
(8647 rep)
Sep 29, 2021, 01:57 PM
Last activity: Sep 29, 2021, 03:26 PM
Last activity: Sep 29, 2021, 03:26 PM