0

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

1 Answer 1

2

Our crontab has a line similar to

if ! mountpoint -q /mnt/beegfs_backup ;then mount /mnt/beegfs_backup;fi && rsnapshot daily

You can adapt this to your script.

1
  • thanks. going to use if mountpoint -q /bkup; then rsnapshot daily in /etc/crontab
    – ron
    Commented Sep 29, 2021 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .