3

Is it possible using the Windows 10 Windows Subsystem for Linux (WSL) to have a rsync server running on a Windows box?

We have a linux rsync system that polls Windows boxes currently running DeltaCopy, but we occasionally have odd problems. Hoping that the 'built-in' WSL rsync might improve things, but don't know how to arrange to have it run as a server.

phuclv
  • 159
  • 16
Torfey
  • 33
  • 1
  • 1
  • 5
  • 1
    One of the reasons to build WSL into Windows was so that users would be able to download and run pre-built Docker containers off the Docker hub right away. So why not just try it, [set up docker](https://www.reddit.com/r/docker/comments/5eggwo/running_docker_on_windows_subsystem_for_linux_wsl/?st=j8vq0t2g&sh=1f872783) and load one of the rsync-servers off the hub? – the-wabbit Oct 17 '17 at 14:47
  • possible duplicate https://askubuntu.com/questions/914551/how-to-raise-up-a-rsync-environment-on-wsl-to-mirror-changes-from-pc-to-vps – Mr. Raspberry Oct 17 '17 at 15:58
  • I am a linux user, but naive when it comes to Windows. Haven't heard of Docker, alas. Will investigate. And on the askubuntu answer, it appears that there must be some additional rsync under WSL config going on that isn't mentioned to get the windows-side rsync to listen, yes? – Torfey Oct 17 '17 at 17:00

3 Answers3

3

I've managed to have it working on my system. It's not exactly a daemon in the sense of a Windows service but more of a background task of the current user, but it works for me.

Installation and initial configuration

I installed WSL for my user and Debian as the linux application of choice. Anyway it should work with any distribution as it only uses rsync.

On my linux home directory I've created two files: rsyncd.conf and secrets.

The conf file:

auth users = nas
secrets file = /home/peter/rsyncd/secrets
hosts allow = 192.168.1.5,192.168.1.11
log file = /home/peter/rsyncd/rsyncd.log
port = 8730
use chroot = false
read only = false

[N_Almacen]
    path = /mnt/n/Almacen/rsyncd

[N_AlmacenNB]
    path = /mnt/n/AlmacenNB/rsyncd

I'm using port 8730 to avoid having to run the daemon as root. That's also the reason I've disabled chroot.

The secrets file contains usernames and passwords as usual.

How to run it

Finally the tricky part. How to run it?

You can test it with this command:

rsync --daemon --config=/home/peter/rsyncd/rsyncd.conf --no-detach

When you are confident that the configuration is working you can remove the --no-detach option and the command will spawn a background task. Even if you close all bash terminals the task will remain in the background.

How to start it automatically in the background

So now how to run automatically on login?

Create a windows shortcut to C:\Windows\System32\wsl.exe and append your command after that. The full command will be:

C:\Windows\System32\wsl.exe rsync --daemon --config=/home/peter/rsyncd/rsyncd.conf

enter image description here

Now you can put this shortcut in the startup folder for your user.

sargue
  • 156
  • 7
2

--rsync-path option can be used to access WSL rsync from another machine. This option is used to specify what program is to be run on the remote machine to start-up rsync. So --rsync-path='wsl rsync' should do the trick.

For example,

rsync -avhP -e ssh local_path host:remote_path --rsync-path='wsl rsync'
  • Thanks a lot, this is work for me! It was necessary to copy files from Windows (where is WSL installed) to local Linux: rsync -av --rsync-path='wsl rsync' user@10.83.22.41:"/mnt/e/directory" ./ – itlux Apr 20 '20 at 12:36
0

Faced with the same problem, I found that the proposed solution did not work in my case. On Win10 Home edition an OpenSSH server was installed, and ssh <user>@<winpc>.some.domain from a Linux system works perfectly. Using --rsync-path='wsl rsync' in the rsync-call resulted in error messages from Win10. Depending on the precise syntax, it reported either 'some syntax error in name' or '"wsl rsync" is not recognised'.

The solution which does work in my case is to create a file on the Win10 machine, named C:\Windows\System32\wslrsync.bat, which contains:

@echo off
wsl rsync %*

combined with using --rsync-path=wslrsync in the rsync-call.

wimpie
  • 1
  • 1