How to Use Rsync on a Synology NAS

In this tutorial, we will look at how to use Rsync on a Synology NAS.

Rsync is a tool that can be used to sync files from one location to another. This tutorial will look at how to use Rsync on a Synology NAS from a general perspective, using a Linux device to show the process. After the initial Rsync job finishes, future backups are incremental (as opposed to full). For this reason, the initial backup will take significantly longer than subsequent backups.

The process below will look at how to use Rsync on a Synology NAS with Linux as the example, but please be aware that there are many devices you can utilize Rsync on!

How to Use Rsync on a Synology NAS

1. Log in to DSM, open the Control Panel, select File Services and ensure that enable rsync service is selected.

synology rsync service

2. Create a Backups shared folder (you can use whatever name you’d like, or can utilize one that already exists) and note the volume number (you will need this later).

creating backups folder

3. Ensure that the user account you will be authenticating with has read/write access to the shared folder.

backups folder permissions

4. Create a subfolder in the shared folder with the name of the PC that you will be backing up (if you don’t want to back up directly to the root folder).

ub-test folder

5. If your firewall is enabled, create a firewall rule that opens port 22 for SSH.

NOTE: you can secure this one step further if you’d like by only opening port 22 traffic to internal IP addresses (use your internal IP address range). This rule must be above any “deny” rules that exist.

ssh firewall rule

6. Log in to your Linux PC (or whatever device you’ll be using) and open Terminal. At this point, we will begin to construct our Rsync command. Many different parameters can be added to a Rsync command, but in this tutorial, we will back up our entire Linux hard drive to our Backups device subfolder on our Synology NAS. The Rsync command will be constructed as follows:

sudo rsync -avnx / [USERNAME]@[NAS IP ADDRESS]:/[NAS VOLUME]/Backups/[DEVICE NAME]
rsync command to access the backups folder

NOTE: the “n” command line parameter above will run a dry run when this is executed. This will NOT copy any files over. It will simply inform the user what files will be copied when the command (with the “n” parameter removed) is executed. It is also important to note that the first “/” in the Rsync command is the source data that we will be copying to the NAS.

7. If this is your first time running the command, you will be asked to accept the ECDSA key fingerprint. Type yes and select the enter key.

ssh fingerprint acceptance

8. Enter the password of your Synology NAS user account that has permission to the shared folder.

NOTE: you might need to enter the password of your Linux user first.

ssh password

9. When the dry run has finished (assuming the results are what you were expecting), remove the “n” parameter, and run the command. When prompted, enter the NAS password once again.

sudo rsync -avx / [USERNAME]@[NAS IP ADDRESS]:/[NAS VOLUME]/Backups/[PC NAME]
rsync command and password

10. When the process is completed, you will see that your files are now on your Synology NAS in the folder we created.

files shown in dsm after rsync

Conclusion – How to Use Rsync on a Synology NAS

This tutorial looked at how to use Rsync on a Synology NAS. The first time executing this, all files will need to be backed up which will take a little longer than subsequent backups. Rsync does incremental backups, which means that it will view the files that are changed and back them up to the Synology NAS.

This process is NOT automated! You can only back up your machines when you execute the command. If you’d like to automate this process by using SSH keys and Cron, please check out our tutorial

It’s always a good idea to back up your Synology NAS offsite. If you’re interested in doing that, check out our tutorials on how to back up your Synology NAS to a Raspberry Pi or Backblaze B2! Thanks for checking out the tutorial on how to use Rsync on a Synology NAS! If you have any questions on how to use Rsync on a Synology NAS, please leave them in the comments!

WunderTech

Frank is an IT professional with 13+ years experience and the creator of WunderTech. He focuses on sharing his experience with others on computer hardware, servers, software, networking, and self-hosted apps. He has a BS in Computer Information Systems and an MBA. Learn more about Frank in his bio.

This Post Has 8 Comments

  1. Domenick

    Does RSYNC keep a continuous back up or does it keep the status synced? Like if I remove folders or anything, will they be removed from the NAS as well or will is just keep everything and never remove stuff?

    1. WunderTech

      Rsync is a command that you can run manually or automate using SSH Keys/Cron. By default, Rsync only copies over the file differences, so the initial backup will take a long time but subsequent backups will be significantly quicker.

      To answer your question, if you run an Rsync today from a Linux PC to a Synology NAS, delete a folder on the Linux PC tomorrow and then run an Rsync again, the folder will still exist on the Synology NAS. Rsync is a great backup tool, but it’s really only good for file-level backups. If you’re interested in doing bare-metal backups, something like Veeam is definitely better.

      Let me know if you have any other questions!

      1. Domenick

        Not sure what you mean by bare-metal backups, but what I would like is just the current folder structure of the Pi. That way if at some point, a cache or garbage file gets backed up it will be deleted if it’s been deleted on the Pi.

        1. WunderTech

          Yes, Rsync will work perfect for that.

          Bare-metal backup means restoring a PC in it’s current state to a new hard drive. Meaning that if you have Linux installed, you would be able to “back up” the current operating system and “restore” it on a new hard drive. Then, when you plug in that new hard drive, it would function the exact same way the current hard drive does (and boot up the operating system). Rsync simply copies the files.

          You are correct that using Rsync would be your best option for a Raspberry Pi. This site has a bunch of different rsync command examples: https://www.linuxtechi.com/rsync-command-examples-linux/

    2. Pete

      use –delete to remove files from the destination that no longer exist on source

  2. Кирилл

    Подскажите пожалуйста, а как тогда восстановить резервную копию c NAS на сервер ?

  3. Liviu

    I am soo frustrated, it simply does not work for me. I try to rsync some VM backups to my Synology Nas without succes.

    1. WunderTech

      Where is the VM server (on the NAS or somewhere else)? Are you able to access an SMB share from one of the devices?

Comments are closed.