New plugin available: USB Backup

The new plugin ‘USB Backup’ can be used to automatically synchronise a shared folder to an external USB storage device when the USB stick is plugged in.

To configure a backup job, simply plugin the USB storage device you want to use and press the ‘Add’ button. Then select this USB device in the ‘Volume’ combobox and configure the other job options. In the jobs grid panel you can select a job and run it manually, otherwise it will be started when you plug the USB device. A beep occurs when the synchronisation job is started and when it has been finished, additionally an email is send if configured. The sync protocol can be viewed in the ‘Rsync – Jobs’ system logs.

38 thoughts on “New plugin available: USB Backup

  1. Hi,

    Im using this really cool plugin. But there is something that could be improved. In some cases, rsync could corrupt the data. This can happen, when rsync is working in a directory with changing data. This is not a problem for new or deleted files, because rsync creates a file-list before starting. But changing files can be corrupted during sync.

    So two options would be really cool.
    First: do a read-only remount of the data-drive before starting (set by an UI-switch?).
    Second: If the data-drive has an LVM, take a snapshot and let rsync work with the snapshot instead of the real directory.

    As far as I see it, this could be done by adding two additional lines in /var/lib/openmediavault/usbbackup.d/sync-, right? But I don´t know the impact on the UI.

    I would like to test it but /var/lib/openmediavault/usbbackup.d/sync- says:
    #!/bin/sh
    # This configuration file is auto-generated.
    # WARNING: Do not edit this file, your changes will be lost.

    Is there some kind of script-template which i could change to have a ro-mount or snapshot feature?

    Best regards,

    Sebastian

  2. When deleting task, with the latest version of usb-backup:

    Failed to execute command ‘export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C; systemctl stop openmediavault-usbbackup-automountfs@.service 2>&1’ with exit code ‘1’: Failed to stop openmediavault-usbbackup-automountfs@.service: Unit name openmediavault-usbbackup-automountfs@.service is not valid. Failed to get load state of openmediavault-usbbackup-automountfs@.service: Unit name openmediavault-usbbackup-automountfs@.service is not valid.

    Error #0:
    exception ‘OMV\ExecException’ with message ‘Failed to execute command ‘export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C; systemctl stop openmediavault-usbbackup-automountfs@.service 2>&1’ with exit code ‘1’: Failed to stop openmediavault-usbbackup-automountfs@.service: Unit name openmediavault-usbbackup-automountfs@.service is not valid.
    Failed to get load state of openmediavault-usbbackup-automountfs@.service: Unit name openmediavault-usbbackup-automountfs@.service is not valid.’ in /usr/share/php/openmediavault/system/process.inc:174
    Stack trace:
    #0 /usr/share/php/openmediavault/system/systemctl.inc(75): OMV\System\Process->execute(Array, 1)
    #1 /usr/share/php/openmediavault/system/systemctl.inc(110): OMV\System\SystemCtl->exec(‘stop’, NULL, false)
    #2 /usr/share/openmediavault/engined/module/usbbackup.inc(82): OMV\System\SystemCtl->disable(true)
    #3 /usr/share/openmediavault/engined/module/usbbackup.inc(49): OMVModuleUsbBackup->updateUnitFiles(‘disable’)
    #4 /usr/share/openmediavault/engined/rpc/config.inc(147): OMVModuleUsbBackup->stopService()
    #5 [internal function]: OMVRpcServiceConfig->applyChanges(Array, Array)
    #6 /usr/share/php/openmediavault/rpc/serviceabstract.inc(124): call_user_func_array(Array, Array)
    #7 /usr/share/php/openmediavault/rpc/serviceabstract.inc(156): OMV\Rpc\ServiceAbstract->callMethod(‘applyChanges’, Array, Array)
    #8 /usr/share/openmediavault/engined/rpc/config.inc(208): OMV\Rpc\ServiceAbstract->callMethodBg(‘applyChanges’, Array, Array)
    #9 [internal function]: OMVRpcServiceConfig->applyChangesBg(Array, Array)
    #10 /usr/share/php/openmediavault/rpc/serviceabstract.inc(124): call_user_func_array(Array, Array)
    #11 /usr/share/php/openmediavault/rpc/rpc.inc(84): OMV\Rpc\ServiceAbstract->callMethod(‘applyChangesBg’, Array, Array)
    #12 /usr/sbin/omv-engined(525): OMV\Rpc\Rpc::call(‘Config’, ‘applyChangesBg’, Array, Array, 1)
    #13 {main}

    Help would be greatly appreciated!

  3. I am getting this error on usb copy for any external USB ! Please help thanks in advance

    Please wait, syncing to …

    s were not transferred (see previous errors) (code 23) at main.c(1060) [sender=3.0.7]
    size is 0 speedup is 0.00

  4. I want to make periodical backups to an external drive. Please add the possibility to select a sub folder for every source folder. It doesn’t make sense to backup all shared folders into the root of the usb drive. For the moment, I made a mount point of all shared folders into one single shared folder and use this for usb backup. Scheduled backups would also be very nice.

    • Sry i got scheduled backups with Rsync now. But i have to mount –bind the root of all shared folders to one new shared folder to get one single rsync job.

    • No. OMV is using the shared folder concept globally. The easiest way to meet your requirememnt you can create a seperate shared folder for the specific directory you want to process.

  5. Hello,

    Is it possible to schedule the backups that have been set up with this plugin ?
    The purpose is to launch the backup every night, and have a successful backup if the usb disk is ever plugged in.

    Also, what is happening if the partition is not mounted ? does the plugin automatically mount the partition before starting, and then unmount it when finished ?

    • The plugin was designed to only start the backup job if the USB device is plugged in, scheduled jobs are not on the todo list. The device is automatically mounted when it is plugged in, the backup job only checks if the mount point exists and throws an error and stops the action if it doesn’t exist. Scheduled jobs should use the RSync service.

  6. Nice addition to OMV, Volker.
    Any consideration given to making the jobs work in the reverse direction, perhaps as a tickable/selectable option?
    E.g. Plug in USB stick and OMV backs up the USB stick content “to” OMV rather than the other way around?
    Bob
    .

  7. I’d like to backup multiple “Shared folders” to the same “Volume”. But that doesn’t seem to be possible.
    Is this a rsync limitation?

    Error #3005:
    exception ‘OMVException’ with message ‘The configuration object is not unique: A backup job already exists for this storage device’ in /var/www/openmediavault/rpc/usbbackup.inc:287
    Stack trace:
    #0 [internal function]: UsbBackupRpc->set(Array)
    #1 /usr/share/php/openmediavault/rpc.inc(265): call_user_func_array(Array, Array)
    #2 /usr/share/php/openmediavault/rpc.inc(98): OMVRpc::exec(‘UsbBackup’, ‘set’, Array)
    #3 /var/www/openmediavault/rpc.php(44): OMVJsonRpcServer->handle()
    #4 {main}

    Greetings,

    • No not to rsync, but how this feature is implemented. If you did not find a solution for you how to adapt this limitation to your scenario, then please open a bugreprt/feature request to support multiple shared volumes.

  8. Could this be Tweaked so that it can be used to backup the “live omv setup” that im running from a usb stick.? The ide plug in a new usb stick and push some button and get a backup of the running OMV on the usb stick…

  9. Hi,
    I’d like to backup the whole OMV-system to a USB-Drive.
    OMV is running on SSD, and data is on 4 HDDs (Raid5).
    How can i add my system-drive to the shared folder?
    Shared folder dropdown shows only my data-raid5 shares.
    In shared folders i cannot select my system volume, only data-raid5 volume.

  10. Was kommt denn schönes mit der 0.5? Wann soll die Version fertig werden?

    Klasse fänd ich eine Integration der Temperatur Sensoren (lm-sensors) unter Systeminformationen/System. Für viele wäre sicher eine Backup/Restore Möglichkeit der Einstellungen interessant. Ist so etwas möglich?

    • Ein komplett neues Backend, d.h. die meisten Änderungen sind unter der Haube und für den normalen Anwender nicht sichtbar, aber die Plugin-Entwickler wird es hoffentlich freuen.

    • Sadly this is the only option if you did not make a manual backup of your config.

      Can you please describe how it happens that you have run a backup job even if the external USB device was not connected?

      Are you sure you have selected the correct external storage device, maybe you are using OMV on a USB stick and did wrongly choose this one.

      • 1) I connected pendrive
        2) it is a usb-backup
        3) I clicked on the ‘ADD’
        4) I chose PENDRIVE (the right one)
        5) I clicked RUN

        system on ATA HDD (8GB)
        omitted mount a pen-drive
        usb-backup that did not check this … created the directory, but I do not mount … copy the contents to the /media/ (vfat not mounted)

        • Problem should be fixed in openmediavault-usbbackup 0.4.2. It checks if the external storage device is mounted before running the rsync command. Package has been released right at the moment.

          • Hello,

            first: great job !
            second: it is possible to write to a pen drive formated in fat32?
            When I plug the pen drive, I have to mount it and after when I launch the backup job, logs say me that the key where not mounted.
            When I format the key in ext3 or ext4, it works without problem.

    • Na kommt drauf an was für eines. Eigentlich bin ich gerade mit 0.5 beschäftigt, das backup Plugin war nur eine kleine Fingerübung um mal wieder was vorzeigbares zu machen und ein bisschen mit Udev zu spielen.

  11. Device ‘/dev/mapper/NAS-BACKUP’ not found
    Error #6000:
    exception ‘OMVException’ with message ‘Device ‘/dev/mapper/NAS-BACKUP’ not found’ in /var/www/openmediavault/rpc/usbbackup.inc:131
    Stack trace:
    #0 [internal function]: UsbBackupRpc->getCandidates(Array)
    #1 /usr/share/php/openmediavault/rpc.inc(265): call_user_func_array(Array, Array)
    #2 /usr/share/php/openmediavault/rpc.inc(98): OMVRpc::exec(‘UsbBackup’, ‘getCandidates’, Array)
    #3 /var/www/openmediavault/rpc.php(44): OMVJsonRpcServer->handle()
    #4 {main}

    (/dev/mapper/NAS-BACKUP -> xfs on LVM2)

      • using usb backup w/o mount USB-drive, makes a copy of the system drive (although it has been selected USB drive)

        I lost my config OMV … df / => used 100% :/
        is it possible to rebuild this file (/etc/openmediavault/config.xml)?

        Error # 3008:
        exception ‘OMVException’ with message ‘Failed to load configuration (4 Fatal error: Document is empty (line = 1, column = 1); Fatal error 4: Start tag expected,’ <'not found (line = 1, column = 1 )) 'in / usr / share / php / openmediavault / config.inc: 344
        Stack trace:
        # 0 / usr / share / php / openmediavault / env.inc (22): require_once ()
        # 1 / var / www / openmediavault / index.php (24): require_once ('/ usr / share / php / …')
        # 2 {main}

        • Sorry, it is not possible to rebuild the config.

          But i do not know why this could be happend to you because the rsync script explicitely checks if the target device exists:

          if [ ! -e /dev/disk/by-uuid/xxxxx ]; then
          echo "External storage device not found!"
          exit 1
          fi

            • You may try this:

              cp /usr/share/openmediavault/templates/config.xml /etc/openmediavault/config.xml
              omv-initsystem

              To get the webgui running try

              omv-firstaid

              • root@nas:/# cp /usr/share/openmediavault/templates/config.xml /etc/openmediavault/config.xml
                root@nas:/# omv-initsystem
                /usr/share/openmediavault/scripts/initsystem.d/20hostname:
                hostname: Name or service not known
                run-parts: /usr/share/openmediavault/scripts/initsystem.d/20hostname exited with return code 1
                root@nas:/# omv-firstaid
                Updating web administration settings. Please wait …

                look good, only @#$ plugins f*cked 🙂

Leave a Comment