making Rsnapshot backup to mount NFS-Share

    • OMV 3.x
    • making Rsnapshot backup to mount NFS-Share


      I am using OMV 3.x it is working fine.
      I use rsnapshot for backup to a NFS-mounted directory. But when the remote NFS-server is not running, rsnapshot make the backup to the unmount base-directory. How can I "tell" rsnapshot, only backup files, when there exists the NFS-mount?

    • Franzel wrote:

      How can I "tell" rsnapshot, only backup files, when there exists the NFS-mount?

      There is linux/unix utility called autofs, it mounts the requested remote directory on access, after a while it times out and disconnects the share removing the folder also if there is no process accessing it. I can't find options in the rsnapshot man something like check if target directory exists first, but you can give it a try, maybe rsnapshot does it already checks if path exists first. I would check this before proceeding to configure autofs which is not easy to understand at the beginning

      Here you can find a guide for ubuntu
      New wiki
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10 broadcast channel
      openmediavault discord server
    • @subzero79

      thanks for your answer. Autofs was my first inspiration too, but I did not realized that AutoFS removes the base directory when the mount is not used. I think this a solution ...
      I know how to use AutoFs. It it so easy to use.
      I will try it later ( backups are running now ...)
      Thanks for the hint

      a few minutes later ...
      It is not working;-)
      Rsnapshot creates the missing base directory ...

    • I remove the nfs mount statement from fstab.
      I installed autofs.

      Source Code: /etc/auto.master

      1. /media/bcffb16c-a3a2-40a0-995c-c98781c15ed3/synology /etc/auto.synology --timeout=5 --ghost

      Source Code: /etc/auto.synology

      1. NFS -fstype=nfs,rw

      when autofs mounts my nfs-share, the directory /media/.../synology/NFS exists otherwise not.

      Source Code: /var/lib/openmediavault/cron.d/rsnapshot

      1. # backup /media/bcffb16c-a3a2-40a0-995c-c98781c15ed3/extra/ to /media/bcffb16c-a3a2-40a0-995c-c98781c15ed3/synology/NFS/
      2. skip=false
      3. #
      4. # new from here
      5. #
      6. BackupDir=/media/bcffb16c-a3a2-40a0-995c-c98781c15ed3/synology/NFS/
      7. if [ ! -d $BackupDir ]; then
      8. echo "NFS Directory not found"
      9. echo "canceled ;-)"
      10. fi
      11. #
      12. # until here
      13. #
      14. if [ "$1" = "hourly" ]; then skip=true; fi
      15. if [ "$1" = "yearly" ]; then skip=true; fi
      16. if [ "$2" = "78904383-b790-4261-b895-1ce5dc0eaed8" ] || ([ -z "$2" ] && [ $skip = false ]) && [ -d $BackupDir ]; then
      17. targetdir="/media/bcffb16c-a3a2-40a0-995c-c98781c15ed3/synology/NFS//KAI-EXTRA/extra/"
      18. #
      19. #in the 3rd IF the last "&& [ -d $BackupDir ]" is added
      20. #
      Display All

      I create a new variable "BackupDir" and test it in the line, where rsnapshot decides which rsnapshot-task should start (3rd if-statement). I make short output on the console-terminal, if the directory is not found.
      If I change the rsnapshot settings with the WebGui, I must to redo it. I have to search die building-commands from the WebGui.
      But for now it is working for me.