List rsync Modules Remotely

Today I was faced with a problem: I wanted to set up a duply backup task to store data via rsync on a Synology NAS. After clicking around, enabling rsync in the admin interface, creating a user for the task, and getting duply on my original machine running, I could not bring duply (or better, duplicity which does the actual connecting) to talk to the NAS.

There are two syntaxes for the TARGET setting in duply, if you want to use rsync:

  1. rsync://nas-domain/path uses SSH to connect to nas-domain. However on Synology only admins are allowed SSH access.
  2. rsync://nas-domain::module connects to a configured rsync module.

Using (2) I was always presented with a Unknown module error. The first step was therefore to find out, what the heck an rsync module is after all.

Synology themselves tell you to edit /etc/rsyncd.conf to create new modules. But actually, the last thing I want my reliable backup box to do is erroring out on some OS updates, because a config file was changed.

There should be some modules configured already, I reckoned. And lo and behold! There is indeed a way to query defined modules from my original machine:

nmap -p 873 --script rsync-list-modules <your-synology-ip>

This prints something along this line:

Starting Nmap 7.80 ( https://nmap.org ) at 2024-05-28 13:46 CEST
Nmap scan report for 10.0.0.123
Host is up (0.00088s latency).

PORT    STATE SERVICE
873/tcp open  rsync
| rsync-list-modules:
|   homes               homes contains all users' home
|_  home                ~

Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds

This was the missing puzzle piece to set up the TARGET parameter for duply,

TARGET='rsync://user@nas-domain::home/backup'

and now my duply nas full command works like a charm.