Skip to content

007revad/Synology_Config_Backup

Repository files navigation

Synology Config Backup

Backup and export your Synology DSM configuration.

Donate committers.top badge

Description

This is a bash script to backup a Synology's System Config, and optionally copy it via SCP to another server.

Works on DSM 7 and DSM 6

What the script does:

  • Gets your Synology's hostname and the date for use in the backup filename.
    • The Synology's hostname is included in the backup's filename in case you have multiple Synology's.
  • Checks that the script is running as root.
  • Checks that your specified backup location exists.
  • Exports the system config to your specified folder.
  • If REMOTE_BACKUP=yes copies the backup to the specified remote server.

Example of the backup's auto-generated filename: DISKSTATION_2022-11-07_0600.dss


Viewing the result in "Task Scheduler > select task > Action > View Result > view details"

Settings

You need to set TARGET_DIR= near the top of the script (below the header). Set it to the location where you want the backup saved to.

You also need to set REMOTE_BACKUP= to yes if you want to copy the backup to a remote server.

For example:

TARGET_DIR="/volume1/Backups/NAS_System_Backups/DiskStation"
REMOTE_BACKUP=yes

Extra settings for copying the backup to a remote server

If you set REMOTE_BACKUP=yes you also need to set the REMOTE_PORT, REMOTE_IP, REMOTE_DIR, LOCAL_USER and REMOTE_USER to suit your setup.

For example:

REMOTE_PORT=22
REMOTE_IP=192.168.0.100
REMOTE_DIR="/volume1/Backups/NAS_System_Backups/DiskStation"
LOCAL_USER=Bob
REMOTE_USER=Bob

If you set REMOTE2_BACKUP=yes you also need to set the REMOTE2_PORT, REMOTE2_IP, REMOTE2_DIR, LOCAL2_USER and REMOTE2_USER to suit your setup.

For example:

REMOTE2_PORT=22
REMOTE2_IP=192.168.0.111
REMOTE2_DIR="/volume1/Backups/NAS_System_Backups/DiskStation"
LOCAL2_USER=Bob
REMOTE2_USER=Ted

Requirements

If you want to schedule the script to run unattended, and have the script copy the backup to another server you need to have SSH keys setup so SCP can access the remote server without you entering the user's password.

See https://github.com/007revad/Synology_SSH_key_setup for steps on setting up SSH key authentication.

Note: Due to some of the commands used this script needs to be run as root, or be scheduled to run as root.

Download the script

  1. Download the latest version Source code (zip) from https://github.com/007revad/Synology_Config_Backup/releases
  2. Save the download zip file to a folder on the Synology.
  3. Unzip the zip file.

Scheduling the script in Synology's Task Scheduler

See How to schedule a script in Synology Task Scheduler

Running the script via SSH

How to enable SSH and login to DSM via SSH

You run the script in a shell with sudo -s or as root.

sudo -s /path-to-script/synology_config_backup.sh

Note: Replace /path-to-script/ with the actual path to the script on your Synology.