How do I back up data from a Linux device to my Synology NAS via rsync?
Last updated:19 Apr 2022
How do I back up data from a Linux device to my Synology NAS via rsync?
Purpose
This article guides you through backing up your Linux workstation or server data to your Synology NAS using rsync.
Resolution
Configure Synology NAS as the destination server
If you want to back up data from your Linux device to your Synology NAS, you need to enable rsync service on the destination server first before creating a backup task. To enable this function, follow the steps below:
- Log in to DSM using an account belonging to the administrators group, or assign application privileges for the rsync backup destination to a user account (Control Panel > Privileges) and log in with its credentials.1
- Open Control Panel.
- Go to File Services > rsync, and then tick the Enable rsync service checkbox.
- Click Apply to save your settings.
To set up a DSM user with proper privileges on your Synology NAS, please do the following:
- Go to Control Panel > Privileges, and grant the rsync privilege to the user.
- Go to Control Panel > Shared Folder, select a shared folder, click Edit > Permissions, and then grant the Read/Write privilege to the user. Repeat this step to include more shared folders that could be used as backup destinations.
Back up data from a Linux device to your Synology NAS
- The most common way to back up data from a Linux device to Synology NAS is to use rsync to make mirrored folders. You may need to mount the folder on the Synology NAS to your Linux device using CIFS or NFS mount beforehand. The command for this is:
[root@www ~]# rsync -av [source_folder] [destination_folder]
# 1. Make /home/ mirror to /backupdata/home/
[root@www ~]# rsync -av /home /backupdata/
- Alternatively, you can simply execute the following command on your Linux device without having to mount the folder. In the example below, 192.168.55.66 should be replaced with the IP address of your Synology NAS. If you want to back up data to any folders other than the default folder, NetBackup should be replaced with the destination shared folder on your NAS:
rsync -av home/ admin@192.168.55.66::NetBackup/backupdata/
- Data backups can also be encrypted by inserting -e ssh into the command:
rsync -av -e ssh home/ admin@192.168.55.66::NetBackup/backupdata/
- When rsync is running, it will compare the data between your Synology NAS and Linux device. Only modified files will be transferred to save time. In addition, you can make daily backups using a Linux Backup Script.2
Notes:
- If other people want to perform rsync backup from a client that is not Synology NAS, they can only do so using a user account with rsync privileges on your Synology NAS. You can go to Control Panel > User to create a user named rsync, and modify its privileges so that you can use it for sharing.
- For more information on how to access shared folders from Linux, please refer to this article.