USB Backup - is it possible launch a script before rsync start?

  • Hi all, first of all thank you for this magic product, OMV is awesome.


    One question: I use USB Backup plugin for execute backup of my personal files and docker container files to an external usb drive, and it works very well.


    I was wondering if it's possible to launch a script after usb drive is connected and before rsync process is start, and then after usb drive is umounted


    This because I would like to pause the containers before the sync start and unpause it after the sync is finished.


    Is there a way to realize this?


    Some time ago I needed to restore the nextcloudpi docker from usb drive and unfortunately it was in unconsistence state, casued by synced done without pausing/stopping the service.


    Thank you very much :)

  • Is there a way to realize this?

    Not out of the box.


    You could either edit the rsync joby that are created in /var/lib/openmediavault/usbbackup.d, but these jobs will be rewritten in case of an update of the plugin or if you create or delete a new job in the GUI.


    Or you create your own solution based on an udev rule. Here is an example which creates an encrypted backup when an USB device is plugged in. You can skip the encryption part and just see how to create an udev rule to execute a script when a drive is plugged in.

    RE: Encrypted Backup

  • Sorry to bother you, and I realize it's not OMV's own topic, but I'm becoming crazy!


    I wrote the rule for udev,


    ACTION=="add", SUBSYSTEM=="usb", ENV{PRODUCT}=="bc2/aa15/712", RUN=="/script.sh"


    the rule works, but whatever script I put in RUN== doesn't work, in syslog I receive "Process '/script.sh' failed with exit code 1.


    I tried everything, but i can not understand what I'm wrong


    I receive exit code 1 even if in the script I write only #!/bin/bash


    Is there any block or customization in Debian 10 or OMV?


    Thank you very much!

  • Yes, same error :(. I tried to call a systemd process, RUN+="/bin/systemctl start --no-block usbbackup.service , from terminal works, but udev same error :( . I'm going crazy.

  • Eventually I got workaround through creation of systemd service, that check the presence of device and the starts the script. I don't understand why udev doesn't work, but in the end I achieved my goal.


    Thank you very much again :)


    Ciao!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!