publications:synology_trigger_hyper_backup_on_usb_connect
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| publications:synology_trigger_hyper_backup_on_usb_connect [2020/01/08 18:50] – Maik Wodarz | publications: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 | + | The //Synology Diskstation (DS)// |
| My DS-216 has a copy button. | My DS-216 has a copy button. | ||
| - | Using the app forseen | + | Using the app foreseen |
| - | When we talk about backups this is a quite poor solution. | + | Talking |
| - | In addition the copy button action can only handle the front usb port of the Synology. | + | In addition, the // |
| - | Sadly the solution | + | My solution |
| + | I wanted to find a solution without third party software. | ||
| - | The following article describes preconditions, | + | The following article describes preconditions, |
| ====== 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 | + | * //Synology |
| - | * Synlogy USB-Copy app is installed | + | * //Synlogy USB-Copy// app is installed |
| - | * Hyper backup | + | * //Hyper backup// tasks using USB are configured |
| ====== Overview - general workflow ====== | ====== Overview - general workflow ====== | ||
| - | * Create a cron job which checkt | + | * Create a cron job which checks |
| - | * 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 37: | Line 38: | ||
| ====== USB-Copy ====== | ====== USB-Copy ====== | ||
| - | Originaly | + | Originally |
| - | 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 // |
| / | / | ||
| The following screenshot is depicting it. | The following screenshot is depicting it. | ||
| Line 55: | Line 56: | ||
| / | / | ||
| | | ||
| - | 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 / | The trigger checker script / | ||
| {{: | {{: | ||
| - | First the script is checking if it is running already. (avoid duplicate run) | + | 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. (''/ | In order to do so it checks if the activity file exists. (''/ | ||
| Line 68: | 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 | + | Then it determines the trigger file counts. (count directory entries in: |
| / | / | ||
| Line 77: | Line 78: | ||
| So it is possible to connect the second backup drive a bit later or even in the same moment. The backups are handled serial. | So it is possible to connect the second backup drive a bit later or even in the same moment. The backups are handled serial. | ||
| - | What happens when a trigger counter is bigger than Zero?: | + | What happens when a trigger counter is bigger than zero?: |
| * Create activity file (using touch command) | * Create activity file (using touch command) | ||
| * Remove all entries in trigger folders: | * Remove all entries in trigger folders: | ||
| Line 143: | Line 144: | ||
| ====== Synousbcopy ====== | ====== Synousbcopy ====== | ||
| - | ''/ | + | ''/ |
| - | What can synousbcopy do for us? | + | What can '' |
| / | / | ||
| Shows the help. | Shows the help. | ||
| Line 159: | Line 160: | ||
| ====== Script startDatenBackup.sh ====== | ====== Script startDatenBackup.sh ====== | ||
| - | This script or the corresponding counterpart startMediaBackup.sh is the heart of the trigger process. | + | This script or the corresponding counterpart |
| It does the following: | It does the following: | ||
| * activate copy LED blinking | * activate copy LED blinking | ||
| - | * triggers hyper backup task | + | * triggers |
| * waits until the hyper backup task finishes. | * waits until the hyper backup task finishes. | ||
| * Deactivates the copy LED | * Deactivates the copy LED | ||
| Line 198: | Line 199: | ||
| '' | '' | ||
| - | ====== Activity file ('' | + | ====== Activity file (/ |
| ''/ | ''/ | ||
| + | ====== Logging ====== | ||
| + | The scripts ''/ | ||
| + | |||
| + | ====== References ====== | ||
| + | [1] [[https:// | ||
publications/synology_trigger_hyper_backup_on_usb_connect.1578509459.txt.gz · Last modified: by Maik Wodarz
