User Tools

Site Tools


publications:synology_trigger_hyper_backup_on_usb_connect

This is an old revision of the document!


About

This article describes how can be configured an automatic USB hyperbackup, which is triggered by USB-connect.

Introduction

The synology diskstation out of the box isn’t able to start an backup job automatically as reaction of USB hard drive connection.

My DS-216 has a copy button.

Using the app forseen for this button you can do some simple tasks like “copy all files from USB-Drive to a predefined destination folder” or “copy all files in predefined folder to USB drive.

When we talk about backups this is a quite poor solution. Wishable would be a trigger of a hyper backup job. Reason: hyperbackup does maintain a history of files. (like time capsule) and compresses.

In addition the copy button action can only handle the front usb port of the Synology.

Sadly the solution of Bernd Distler [1] is not working anymore because I couldn’t get running the autorun functionality.

The following article describes preconditions, the general workflow as well as the details how it is possible to trigger a hyper backup job start on USB connect event.

Preconditions

  • ssh access to synology nas is enabled and the user is aware how to use it.
  • Basic knowledge about usage of bash and vi editor.
  • Synology hyper backup app is installed
  • Synlogy USB-Copy app is installed
  • Hyper backup jobs using USB are configured.

Overview - general workflow

  • Create a cron job which checkt peridically a predefined file system location for existence of a flag file. (I’ll call it trigger file)
  • Create an USB copy job using USB-Copy app from Synology, which copies a trigger file from a just connected USB drive to predefined location on NAS.
  • When the cron job finds the trigger file and there is still no active job (activity file)
    • Remember that a job is active ⇒ create the activity file (using touch)
    • Remove the trigger file
    • Switch copy LED to blinking mode
    • Start hyper backup task
    • Wait until the hyper backup task has finished
    • Wait some seconds
    • Deactivate copy LED
    • Remove activity file

USB-Copy

Originaly the USB-Copy app from Synology is intendet to do simple jobs like “copy file from USB drive to NAS” or “copy files from NAS to USB drive” when the copy button is pressed or a specific backup medium is detected. (UUID) It has to be installed by Synology package center.

Actions caused by copy button are affecting only the fron USB port while USB detecting actions are working for the back site USB ports as well.

For my objective – triggering a hyper backup job – I simply copy a flag file from predefined location on USB drive to a predefined location on NAS. So after connecting the USB drive a file named autobackup is copied to

/volume1/Shared/USB_AUTO_BACKUP/TRIGGERS/DATEN/autobackup

The following screenshot is depicting it.

The same has to be done for the other USB drive:

/volume1/Shared/USB_AUTO_BACKUP/TRIGGERS/MEDIA/autobackup 

The USB-Copy program lets beep the NAS after connecting twice.

After finishing the trigger file it beebs again twice.

Trigger check

The trigger checker script /opt/bin/checkTrigger.sh is called by cron every minute. First the script is checking if it is running already. (avoid duplicate run)

In order to do so it checks if the activity file exists. (/opt/var/dataBackupRunning)

publications/synology_trigger_hyper_backup_on_usb_connect.1578508719.txt.gz · Last modified: 2020/01/08 18:38 by Maik Wodarz

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki