A Hack For Synology To Do Off-Site Backups

Please Note that This IS NOT being ACTIVELY UPDATED. It may void your warranty! 

bootstrap theme

Off-Site Backups On The Cheap

For the small home, or work office the Synology web server performs admirably. One of the nice things about the system is that it is easily customizable. (For examples see the forums) In my case I administer a small office. When it came time to replace the workplace backup server (a small DIY RAID 1 server) it made sense to buy a solution rather than rolling my own again. The technology had progressed to a point where off-the-shelf hardware/software solution was feasible.

Sparing no expense, I went with Synology because it seemed to be the highest quality. The cost is higher than most others but the feature set is fairly rich, and the system is easily customizable. Contrast this with the Iomega NAS solutions which are cheaper, but a pain to work with because they are needlessly locked-down. (I know because I purchased an Iomega ix2-200 NAS for my personal use. While it was cheap, the system is very closed, and it seems to me, brittle.)

Backing Up To A Portable Drive With USB

Basically, our desired solution required that we have a way of generating backups that we can take off-site. The USB copy button on the synology seems to be an ideal solution. Unfortunately, the out-of-the-box functionality is that this button copies the contents from the usb to the NAS we wanted the reverse...

So, the hack involves changing on Synology file that gets called when the button is pressed with our own script.


First, you need to be able to ssh into your Synology box. This will void your software support, so think about this before you do it!

Copy over the following files:


Put getUsbDrive.sh into /usr/local/src. This is an original script written by me that will search all the USB ports for a USB drive with a folder named "magic" in the top level. You can configure the name of this directory to copy files to in the script.

The other file synousbcopy will replace the Synology file of the same name. Be sure to backup the original Synology synousbcopy file before you replace it!

A Quick Aside

Some caution needs to be exercised here. It seems to me that Synology has written a layer on top of the standard unix system. It seems that this is undocumented, so making a change like this is strictly at your own risk. The big problem is that Synology's management software doesn't seem to automatically know about all changes to the underlying operating system that it does not perform. Moreover, the software seems to be written in such a way that there is no way to tell the Synology software to re-check it's assumptions.

For example, if you unmount a drive via the command-line Synology won't know. So if you check the web interface the output will be misleading. If you re-mount the drive Synology won't know the difference. The problem is that Synology appears to need to do a few things to the disk for the management interface to be consistent.

In our case, we don't care if the off-site USB drive is not handled properly by the Synology GUI. We just want to be sure that all the data we want is properly copied over. I'm not sure if there are deeper implications to this strategy. Use at your own risk!

Installation part 2: Almost There...

Now, alter the synousbcopy script to contain the path to the directory on the NAS you want to do an off-site backup of. The script contains an example of "copy" but you should probably use rsync if you are copying large numbers of files.

Then your done! Everytime the copy button is pressed, the files from your source directory on the NAS will be copied/rsynced onto your USB drive in the directory called "magic".

How Will I Know It Worked?

The lights on the NAS will blink when it is working, and return to solid when it is done. The system will beep if there are any problems. You can also check the log. Both the log file location and name can be configured at the top of synousbcopy.

# ---------------------------------------------------
# Jon MacKay
# Custom script to run after copy button pressed
# Wed, Jan 20, 2010
# ---------------------------------------------------

Where Is Synousbcopy Located?

Hmm... good question. I don't have the system with me anymore, but you can always find it by using something like:

find / -type f -name "synousbcopy"

Please let me know if there are any issues. I have posted the working version not the very final version. If there is demand I will post the final version (which contains rsync code rather than a simple copy statement.)

While every effort has been made to ensure that this software works correctly, please use this software at your own risk! No warranty is expressed or implied. 


While every effort has been made to ensure that this software works correctly, please use this software at your own risk! No warranty is expressed or implied.

© Copyright 2023 Jon MacKay. All Rights Reserved.