Automatic backups to a USB disk on your Synology NAS

Context

I’m a hobbyist photographer and I have about 30’000 images that I keep on my Synology drive. My NAS is a core part of my workflow, but bad things do happen. If they do, I still need to be able to access my images while I’m getting my NAS repaired, or replaced.

I don’t have time to do any of this manually, so I’ve automated the process of backing up my images once a week or on-demand from my NAS to my external USB disk.

You will need…

  1. A USB disk large enough to hold all your images. Ideally, a disk that you can leave plugged in for an extended period of time.
  2. A Synology NAS
  3. Some photos
  4. Shell access to your Synology NAS drive.

 

For this example, I will be using the username “myork” and my NAS is called “yoda”.

 

 

Setup Steps

Plug your external USB drive into the back of your Synology NAS. If it is a USB 3 device, be sure to use the blue USB ports if available.

You should be able to see it in the external drives tab of your Synology NAS web console.

external-disk-settings

here you can see it’s been mounted automatically and a new shared folder called usbshare1 will now be visible in your folder list.

disk-list

 

Collect the information about your files and your external disk.

Log into your Synology web console and ensure SSH is enabled.

enable-ssh

Once the service has been enabled, you can then ssh into the Synology NAS.

ssh myork@yoda
...
myork@yoda:~$

As we know the drive is mounted under the name “usbshare1” we can get the full path from the ssh console.

myork@yoda:~$ mount | grep -i usbshare | awk '{print $3}'
/volumeUSB1/usbshare

The result tells us where the Synology OS has mounted the disk on “/volumeUSB1/usbshare”. Now we need to locate all of our photos.

Fortunately, we can do this from the Synology web console. Open the file browser and get the properties of your photo folder.

get-vol-name

 

Make a note of the location. In my case it is /volume1/photo.

Now, we can use a tool called rsync to help up backup our files.

 

The command will look like

/bin/rsync -avzh /volume1/photo /volumeUSB1/usbshare/

 

where /volume1/photo is the source of my files, and /volumeUSB1/usbshare/ is the destination (my external USB disk).

 

Create the task

In the control panel of the Synology web console, click “Task Scheduler”

udscript

Give the task a useful name and run it as your own user. Do not use root as this is the UNIX/Linux super-user and any mistake could damage your system. In my case, I’m using the myork user.

run-user

Click the task settings tab, and put the command into the “user-defined script” box. Feel free to get it to email you if you want that. The option around abnormal termination relies upon the command exiting with a non-zero exit code, which will work with rsync.

runscript-command

Now select when you’d like this to run. Please bear in mind that a disk copy could take some time to run, so you’ll probably want to run this once a week, or maybe daily.

runwhen

You can then attempt a test run of your script and see if your backups are created.

test-run

That’s about it. If you find this useful, or your have any suggestions, please let me know.

Thanks

Matt

Automatic backups to a USB disk on your Synology NAS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.