Hi,
as many threads in many online sources about backup my Synology using rsync to my WD MyCloud Mirror (Gen 2) did not work fully, I wanted to give you all information with that it worked for me.
Disclaimer
I’m not an expert and this is not an official documentation.
This guide is based on trial and error and information gathered from various online sources.
It worked for me, but please double-check everything and proceed at your own risk.
Goal:
- Backup using rsync from Synology NAS to WD MyCloud Mirror
- Backup destination on WD MyCloud is not visible via SMB to prevent ransomware attacks to find it
- Not using SSH for the backup task
- Auto start rsync server at each boot
- Do not use “
vi” editor as it may be hard for beginners, else use “echo” or “cat”
Prerequisites:
- I tried first using OS3 (FW: 2.42.115) but I did not manage to run it on boot as
/etcis renewed each boot and I did not find any way on OS3 to run a custom boot script at startup - So I updated to OS5 (FW: 5.32.102) as there it is possible to re-use the init script from the App “USBBackups“ out of the App store to run a custom script at auto start
- Have both the IP of your WD (here
192.168.1.35) and your Synology (here192.168.1.25)
Step-by-Step instructions:
Commands on web interface
- Enable SSH on WD with strong password
- Install USBBackups from AppStore (only used to have a custom boot script)
- Create new user on WD web interface, I used
hyperbackupuserwith strong password (I once had issues with special characters but I do not know if it really was the issue - I did not use them but increased the length)
Create needed rsync paths and configs
-
Log in with SSH user sshd on the WD - on Windows in terminal with command
ssh sshd@192.168.1.35- you will be root automatically when using sshd for ssh login
-
Get id of new user with following command and write down uid = and gid of “share”. In my case: uid=1002(hyperbackupuser) and gid=1000(share)
id hyperbackupuser
-
Create 2 new folders on the NAS and assign to user:
mkdir -p /mnt/HD/HD_a2/rsyncmkdir -p /mnt/HD/HD_a2/rsync_hyperbackupchown hyperbackupuser:share /mnt/HD/HD_a2/rsync_hyperbackupchmod 700 /mnt/HD/HD_a2/rsync_hyperbackup
-
Create rsyncd.conf (make sure to replace uid =, gid = and hosts allow = with the correct values. hosts allow = should be the IP of your Synology NAS here 192.168.1.25)
cat <<'EOF' > /mnt/HD/HD_a2/rsync/rsyncd.conf
pid file = /mnt/HD/HD_a2/rsync/rsyncd.pid
lock file = /mnt/HD/HD_a2/rsync/rsync.lock
log file = /mnt/HD/HD_a2/rsync/rsync.log
[BKP]
path = /mnt/HD/HD_a2/rsync_hyperbackup
use chroot = no
uid = 1002
gid = 1000
read only = no
list = yes
auth users = hyperbackupuser
secrets file = /mnt/HD/HD_a2/rsync/rsyncd.secrets
hosts allow = 192.168.1.25
EOF
- set permissions (readable by all, writable only by root)
chmod 644 /mnt/HD/HD_a2/rsync/rsyncd.conf
- create rsyncd.secrets with your password - replace the password with the user password of hyperbackupuser
echo 'hyperbackupuser:YOUR_PASSWORD' > /mnt/HD/HD_a2/rsync/rsyncd.secrets
- set rights to root only
chmod 600 /mnt/HD/HD_a2/rsync/rsyncd.secrets
Create autostart script to start rsyncd each boot
- Make a backup of the init.sh - just in case
cp /shares/Volume_1/Nas_Prog/USBBackups/init.sh /shares/Volume_1/Nas_Prog/USBBackups/init.sh.bak
- Attach the wanted code at the end of the USBBackups App init.sh
cat <<'EOF' >> /shares/Volume_1/Nas_Prog/USBBackups/init.sh
echo "Starting rsync with custom settings..."
# Start rsync daemon with persistent config
/usr/sbin/rsync --daemon --config=/mnt/HD/HD_a2/rsync/rsyncd.conf
EOF
You can reboot now and try to connect via Synolgy
reboot
Synology config
- In HyperBackup create new task with rsync as target and use the data from above
Checkup
- rsync daemon is running after reboot
ps | grep '[r]sync'- should return something with
/mnt/HD/HD_a2/rsync/rsyncd.confin it
- rsync is listening on port 873 (LAN only)
netstat -tulpen | grep 873
- Backup destination is NOT exposed as SMB share
ls -la /shares- backup folder must not appear here
- Backup data directory permissions are locked down
ls -ld /mnt/HD/HD_a2/rsync_hyperbackup- Expected output starts with:
drwx------
- rsync secrets file is protected
ls -l /mnt/HD/HD_a2/rsync/rsyncd.secrets- Expected output starts with:
-rw-------
Hints / Tips / Tricks and Final cleanup
- In my case following was essential in rsyncd.conf:
use chroot = no(this was not needed in OS3 as far as I remember)- do not use
max connections = 1/timeout = 600as this made Synology do not get connection to it
- The backup directory name must not match the username, otherwise WD OS5 will auto-create an SMB share.
- Be careful with special characters in passwords
- You should not see the folder “rsync_hyperbackup” the the web gui - so no SMB access
- You can disable SSH access again if everything works fine