Remote Backup Server Problem

I have a media server (Debian) and a remote storage backup server (rocky 9 with NFS setup). Everything works fine, but I have an unavoidable situation that may cause some issues and I would like to seek opinions from here.

According to some documentation, I can make a local share file like so.

  1. On rocky server, install NFS, create a directory (e.g /mymedia/backup) and share it through the network.
  2. On Debian server, create a directory (e.g /home/user/backup-directory), and then mount the rocky share file to the directory created earlier.
  3. To make an automated daily backup, I use rsync and crontab and set it to do full/partial backup every 12am.

The problem is, sudden power outages often happen at the remote backup site and causing connection breakage between the 2 servers. Assuming there is a power outage right at 12am and the Debian is going to backup the media, it will cause the Debian to “recopy” everything into its own local drive since the directory as mentioned earlier is not mounted to the backup site. Is there a way like to make the debian server to check if the rocky server is ready/not ready before backing up data?

Sorry for the long story and your help is highly appreciated. :saluting_face:

I would look at using something like Restic that can handle all the backup logic for you (mounting / unmounting the destination, doing backups as necessary, ignoring backup tasks when already completed, etc).

Sorry, I did the annoying thing of ignoring the question you directly asked, in favor of trying to address your overall backup problem. If you want to keep using your current system, I suppose you could just add a line to your script that checks if the directory is mounted to the right fs, using findmnt.

1 Like

Don’t worry about it. In fact I would love to hear more opinions to learn more stuff. But for now, I still can’t try the solutions you have given. I’ll update you once I’ve done testing your ideas. Thanks a lot.

Does Debian have systemd, like Rocky does?
If yes, the /etc/fstab in Debian server could have an entry like this:

rocky:/mymedia/backup  /home/user/backup-directory  nfs  defaults,tcp,port=2049,acl,noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=300  0 0

The noauto,nofail basically say that system can boot without mounting the share.
The x-systemd.automount,x-systemd.idle-timeout=300 tell systemd to create an automount unit on boot that will watch the /home/user/backup-directory. Whenever some process tries to use that directory, it is mounted from the rocky server, and if it is not used for 5 minutes (300 sec), then it is automatically unmounted.

That way the rsync makes the system (re)mount the share “on need”, and most of the time the share remains not mounted. (Not completely sure how the mount goes if the server is inaccessible.)

If systemd can’t do that in Debian, there should be at least autofs for the same purpose.

1 Like

In the end, I decided to use findmnt in my script to check if the drive is properly mounted to the correct directory/path. I find this rather easy to implement. Thanks a lot.

For backup, you can use rsync to backup your data without using nfs mount at all. Set up rsync server on the Debian server(open port 873), and do the backup on Rocky server. If the connection is broken(like power outage, network disconnected), backup just fails. Also you can set up the incremental backup after rsync with “/bin/cp -RlpP” to a new folder daily.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.