[GUIDE] running rsync daemon

Here is a guide on how to setup rsync daemon on mycloud gen2 device.

  • To run rsync daemon you will need a configuration file and a secret file (for password storage). By default they should be created as /etc/rsyncd.conf and /etc/rsyncd.secrets. However /etc/ is cleaned on every reboot, so to avoid this let’s create this files in some of your shared folder.

  • Your shared folders are in /dev/sda2 mounted at “/mnt/HD/HD_a2/”, you can use ls command with tab completion over ssh to find it out. For rest of this guide I will use “/mnt/HD/HD_a2/BackUP” folder.

  • Use vi or nano to create secrets file

vi /mnt/HD/HD_a2/BackUP/rsyncd.secrets

add your “username:password”, one per line, you can keep password blank. In my case it like this

#cat /mnt/HD/HD_a2/BackUP/rsyncd.secrets 
root:
sharad:
  • Now create rsync configuration file, in my case this is
#cat /mnt/HD/HD_a2/BackUP/rsyncd.conf
#rsync --config=/mnt/HD/HD_a2/BackUP/rsyncd.conf --daemon
log file=/var/log/rsync.log

[shares]
path=/mnt/HD/HD_a2/
uid=0
gid=0
auth users=root:rw,sharad:rw
read only=no
list=yes
secrets file=/mnt/HD/HD_a2/BackUP/rsyncd.secrets
hosts allow=pathy

Here [shares] is the name of module, you use with rsync daemon, you may have multiple modules.
only users under ‘auth users=’ can connect with the daemon, rw is for read and write access, ro for readonly.
Put your path to secret file in ‘secrets file=’
in ‘hosts allow=’ you can use either host name of host ip address like ‘192.168.1.101:255.255.255.0’, multiple hosts can be used (comma separated)

  • Now run rsync like this

rsync --config=/mnt/HD/HD_a2/<yoursharefolder>/rsyncd.secrets --daemon

  • You will need to restart rsync every reboot, or if you have installed WDCrack you can add the rsync line to “/mnt/HD/HD_a2/Nas_Prog/init.sh”

  • Doing the BACKUP

You will need to run rsync from your host computer to connect with rsync deamon on mycloud and transfer it’s data. For this you will need ipaddress of mycloud , name of the module (we uses shares), allowed users and their password.
rsync --<options> </path/to/backup/folder> rsync://<user>@<mycloudip>:<portofrsync>/<module>/<sharefolder>

Once you run this if rysnc will ask for your password on command line, give the password as per your rsyncd.secrets and transfer will begin.

If you get any errors, check the /var/log/rsync.log on mycloud, to find out error.
Below is the command I use to backup my entire home folder excluding some folders.

rsync -a --progress --links --safe-links --delete --exclude={".cache/*","Music/*","Downloads/*","Videos/*","Pictures/*","qemu/*","mount/*"} /home/sharad/ rsync://root@192.168.0.101:873/shares/BackUP/home

  • Scripting and running backup automatically

To use rsync in script you will need to specify your password as environmental variable before running above code. Here is the example I use (in my linux machine running archlinux). Here I am using blank password. I am running this script as root user otherwise some of the file will be unreadable on my host, suite your needs.

#!/bin/bash
# use with "su"

[ $(id -u) != 0 ] && echo "must run as root user" && exit

##########################################
#### RSYNC OVER SSH WITH RSYNC DAEMON ####
##########################################

# avoid password prompt #
export RSYNC_PASSWORD=""

# backup home # --links is required for --safe-links to have any effect
rsync -a --progress --links --safe-links --delete --exclude={".cache/*","Music/*","Downloads/*","Videos/*","Pictures/*","qemu/*","mount/*"} /home/sharad/ rsync://root@192.168.0.101:873/shares/BackUP/home
# backup /etc configs
rsync -a --progress --links --safe-links --delete /etc/ rsync://root@192.168.0.101:873/shares/BackUP/etc```

To run this automatically you can use cronjob on your host machine.
3 Likes

Thanks for posting. This may help some folks.

1 Like

Hi,

I would like to know how restart rsync after reboot within WDcrack ?

Regard

This is already discussed in the first post.

At first, thank’s a lot for your answer… So, In fact, WDcrack is not installed on my Disk. Is there a another solution to lauch rsync when the disk restart ?

Thank’s for your answer.

Regard’s

You have to run that manually using ssh, everytime you start mycloud.

Do you please how to install WDcrack on my WD My cloud ?

Thank’s

Read this page, WDCrack is part of this apps

I had a lot of hopes on this, then began to figure out this was full of typos. Maybe comb through this and clean it up so a person following it does not have to figure out what you were trying to say (for simple starters rsync/rysnc)…

Am i wrong or there are many [code] empty blocks?
I’m a beginner.
Can you repost a more readable version?
Thanks.

Did some clean-up and corrections.
I am no longer using original OS of MyCloud, ( using alpine linux), so cannot test this. If you use this kindly update here if it works for you or not.

I haven’t installed WDcrack. Just add the following line in
/usr/local/config/wdlog.conf

/usr/sbin/rsync --config=/mnt/HD/HD_a2//rsyncd.conf --daemon

works well :slight_smile:

I don’t know what happens when I perform a firmware update. I have disabled automatic updates.

1 Like

Do you need to restart rsync after reboot or it starts itself ?
I am not using official operating system, so couldn’t test it, but if you are able to start the daemon on reboot without WDcrack, it is good find.