User Tools

Site Tools


publications:synology_trigger_hyper_backup_on_usb_connect

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
publications:synology_trigger_hyper_backup_on_usb_connect [2020/01/08 19:47] – [Script startDatenBackup.sh] Maik Wodarzpublications:synology_trigger_hyper_backup_on_usb_connect [2022/05/01 11:01] (current) Maik Wodarz
Line 1: Line 1:
 ====== About ====== ====== About ======
-This article describes how can be configured an automatic USB hyperbackup, which is triggered by USB-connect.+This article describes how can be configured an automatic USB //hyper backup//, which is triggered by USB-connect.
 ====== Introduction ====== ====== Introduction ======
-The synology diskstation out of the box isn’t able to start an backup job automatically as reaction of USB hard drive connection.+The //Synology Diskstation (DS)// 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. 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.+Using the app foreseen 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 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 does compression.+Talking about backupsthis isn'a solution. Desired would be a trigger for a hyper backup job. Reason: //hyper backup// does maintain a history of files. (like time capsule) and does compression.
  
-In addition the copy button action can only handle the front usb port of the Synology.+In additionthe //Copy// button action can only handle the front USB port of the //Synology DS//.
  
-My solution is derived from Bernd Distler's [1] solution. Bernd Distler is using autorun, a 3th party package.+My solution is derived from Bernd Distler's [1] solution. Bernd Distler is using //autorun//, a 3th party package.
 I wanted to find a solution without third party software. I wanted to find a solution without third party software.
  
-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.+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 ====== ====== Preconditions ======
   * SSH access to Synology NAS is enabled and the user is aware how to use it   * 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   * Basic knowledge about usage of BASH and VI editor
-  * Synology //hyper backup// app is installed +  * //Synology Hyper backup// app is installed 
-  * Synlogy //USB-Copy// app is installed+  * //Synlogy USB-Copy// app is installed
   * //Hyper backup// tasks using USB are configured   * //Hyper backup// tasks using USB are configured
  
 ====== Overview - general workflow ====== ====== 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 a cron job which checks 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.   * 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)+  * When the cron job finds the trigger file and there is still no active job (activity file), then:
     * Remember that a job is active => create the activity file (using touch)     * Remember that a job is active => create the activity file (using touch)
     * Remove the trigger file     * Remove the trigger file
Line 38: Line 38:
  
 ====== USB-Copy ====== ====== 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.+Originally the //USB-Copy// app from Synology is intended 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.+Actions caused by copy button are affecting only the front 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+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   /volume1/Shared/USB_AUTO_BACKUP/TRIGGERS/DATEN/autobackup
 The following screenshot is depicting it. The following screenshot is depicting it.
Line 58: Line 58:
 The //USB-Copy// program lets beep the NAS after connecting twice. The //USB-Copy// program lets beep the NAS after connecting twice.
  
-After finishing the trigger file it beebs again twice.+After finishing the trigger file it beeps again twice.
  
 ====== Trigger check ====== ====== Trigger check ======
 The trigger checker script /opt/bin/checkTrigger.sh is called by cron every minute. The trigger checker script /opt/bin/checkTrigger.sh is called by cron every minute.
 {{:publications:2020-01-08_13_34_42-wodarz_burstnas_.png?600|}} {{:publications:2020-01-08_13_34_42-wodarz_burstnas_.png?600|}}
-First the script is checking if it is running already. (avoid duplicate run)+Firstthe 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'') In order to do so it checks if the activity file exists. (''/opt/var/dataBackupRunning'')
Line 69: Line 69:
 If the activity file exists, it terminates immediately. Otherwise it continues. If the activity file exists, it terminates immediately. Otherwise it continues.
  
-Then it determines the trigger file counts. (counts directory entries in:+Then it determines the trigger file counts. (count directory entries in:
  
   /volume1/Shared/USB_AUTO_BACKUP/TRIGGERS/DATEN/ and    /volume1/Shared/USB_AUTO_BACKUP/TRIGGERS/DATEN/ and 
publications/synology_trigger_hyper_backup_on_usb_connect.txt · Last modified: 2022/05/01 11:01 by Maik Wodarz

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki