In this tutorial, we will look at how you can backup a Linux PC to a Synology NAS using Rsync.
Rsync is a Linux tool that can be used to sync files from one location to another. After the initial Rsync job finishes, your future backups will be incremental (as opposed to full). For this reason, the initial backup will take significantly longer than subsequent backups.
1. Login to DSM, open the “Control Panel”, go to “File Services” and ensure that “enable rsync service” is checked.
2. Create a “Backups” folder and note the volume number (you will need this later).
3. Ensure that the user account that you will be authenticating with has read/write access.
4. Create a subfolder in the “Backups” folder with the name of the PC that you will be backing up.
5. If your firewall is enabled, create a firewall rule that opens port 22. 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.
6. Login to your Linux PC and open Terminal. At this point, we will begin to construct our Rsync command. Many different parameters can be added to an Rsync command, but in this tutorial, we will back up our entire Linux hard drive to our “Backups” PC subfolder on our Synology NAS. The Rsync command will be constructed as follows:
sudo rsync -avnx / [USERNAME]@[NAS IP ADDRESS]:/[NAS VOLUME]/Backups/[PC NAME]
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”.
8. Enter the password of your NAS user. NOTE: you might need to enter the password of your Linux user first.
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]
10. When the process is completed, you will see that your files are now on your Synology NAS in the folder we created.
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 will only be able to 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!