#linux #server #homelab

Rsync is an efficient tool for file transfers, often used for backups due to its speed and flexibility. This guide will explain how to use it to back up a Linux server to a Synology NAS.

1. Set Up Rsync on the Synology NAS

  • Navigate to Control Panel > File Services > Rsync.
  • Enable the rsync service.
  • Create a backup folder where your server will send its files.
  • Optional: Change the SSH port and create a dedicated user for rsync access.


2. Set Up Rsync on the Linux Server

To back up your server to the NAS, run the following command on the Linux server:
rsync --recursive --archive --verbose --compress --one-file-system --human-readable --dry-run --port=222 -e 'ssh -p 222' / rsync-bot@192.168.1.2:/path/to/destination


Key Options in the Command:

  • --recursive: Copy directories and their contents recursively.
  • --archive: Preserve symbolic links, permissions, timestamps, and more.
  • --verbose: Show detailed progress of the transfer.
  • --compress: Compress file data during transfer to save bandwidth.
  • --one-file-system: Stay within the same filesystem (avoid mounting other drives).
  • --human-readable: Display file sizes in a human-readable format (e.g., KB, MB).
  • --dry-run: Simulate the command to show what would happen without making actual changes (remove it to run the command for real).
  • --port=222: Use a custom SSH port (replace with the correct port for your NAS).
  • -e 'ssh -p 222': Specify the use of SSH for the transfer and the custom port.
  • /: Source directory (root folder of the server in this case).
  • rsync-bot@192.168.1.2:/path/to/destination: Destination directory on the NAS. Replace with the appropriate IP address and folder path.


3. Run the Backup

After verifying the --dry-run output (it shows the files that would be copied), remove --dry-run and execute the command to perform the actual backup.