Skip to content

Set Up BorgBackup on Synology DiskStation

It’s possible to install BorgBackup on a Synology NAS device and use it for offsite backups to BorgBase. The following steps don’t require terminal access and set up a regular task in the DSM web interface.

Step 1 – Install BorgBackup and Borgmatic

Section titled “Step 1 – Install BorgBackup and Borgmatic”

SynoCommunity provides an updated Borg package for DSM. It also includes Borgmatic, which is a wrapper around Borg to manage configs, pruning, and repository checks.

To install it, follow the steps outlined on their website or below:

  1. Log in to the DSM web interface.
  2. Open Package Center.
  3. Go to Settings > Package Sources and click Add.
  4. Enter SynoCommunity as the name and https://packages.synocommunity.com as the location.
Adding SynoCommunity package source in Synology Package Center

You should now see a new Community entry on the left side that has Borg listed as a package. Click Install to install Borg together with Python 3.

Step 2 – Create Hidden Shared Folder for Borg Config Files

Section titled “Step 2 – Create Hidden Shared Folder for Borg Config Files”

Now, add a new hidden share to have easy access to Borg config files:

  1. Open the DSM Control Panel and choose Shared Folder.
  2. Click Create, enter a name and description, and choose to hide the folder. You also won’t need the recycle bin.
Creating a hidden shared folder in Synology DSM Control Panel

Next, create a new private key for the Synology NAS and place it in the folder. You can either create the key on the device itself by logging in via SSH (advanced option) or create it locally and copy it over:

Terminal window
ssh-keygen -t ecdsa -b 384 -f ./id_synology

You will end up with two files: the private key (id_synology) and the public key (id_synology.pub). Copy the private key to the new BorgBackup shared folder on the DSM and add the public key under SSH Keys in your BorgBase account.

Next, add a Borgmatic config file in the shared folder created above. You can copy a template from the BorgBase control panel under Setup Wizard or from Borgmatic’s website. A minimal example (borgmatic.yml):

# List of source directories to back up.
source_directories:
- /volume1/data
- /volume1/more-data
# Paths of local or remote repositories to back up to.
repositories:
- path: ssh://xxxxx@xxxxx.repo.borgbase.com/./repo
# Point to your private key.
ssh_command: ssh -i /path/to/private/key
# Add passphrase used during repo init.
encryption_passphrase: "my-secret-passphrase-8859849"
# Retention policy for how many backups to keep.
keep_daily: 7
keep_weekly: 4
keep_monthly: 6
# List of checks to run to validate your backups.
checks:
- name: repository
frequency: 4 weeks

See the Borgmatic configuration reference for all available options. At a minimum, adjust:

  • Folders to back up (source_directories)
  • Path to private SSH key (ssh_command)
  • BorgBase repository URL (repositories) — you can also list multiple repositories for geographic redundancy
  • Encryption passphrase used during repository initialization (encryption_passphrase)

Save the contents of the file as e.g. borgmatic.yml.

In this step we add a daily task to create a new Borg archive. This is done in the web interface, where you can choose daily, weekly, or monthly backup frequencies.

First return to the Control Panel, switch to Advanced Mode in the top-left, and open Task Scheduler.

Then click Create > Scheduled Task > User-defined script.

Creating a user-defined scheduled task in Synology Task Scheduler

In the next screen, enter any name for the task. The user should be root so it has full access to all files. The settings under Schedule can be adjusted to fit your needs.

Add the path of your Borgmatic binary and config file under Task Settings, e.g.:

Terminal window
/usr/local/bin/borgmatic -c /path/to/borgmatic.yml create prune compact

To regularly verify the integrity of your backups, add a monthly task for repository checking (please don’t run daily checks, as they put heavy load on our servers):

Terminal window
/usr/local/bin/borgmatic -c /path/to/borgmatic.yml check
Entering the Borgmatic command in Synology Task Settings

That’s it. Now you are ready to run the backup script. To trigger a manual test run, select the new task and click Run. You should see increased CPU usage and upload activity in the resource monitor widget. If there are any errors, you will find them in a log file in the shared folder.

Now you have an efficient offsite backup of your essential data with everything integrated and logged in the web interface.

As always, if you have any additions or questions regarding this guide, feel free to open an issue or pull request in the GitHub repo or email us at hello@borgbase.com.