Rsync and Windows?
Many corporate and heterogeneous networks use the rsync protocol to perform server backups or to keep files synchronized automatically from one or more directories on different machines. Linux natively incorporates the rsync utility and other associated tools, but what do you do when you need to backup Windows folders automatically from a NAS or a remote machine? One option could be to use Samba to read the contents of those folders from Linux, but it would be a fairly complex solution, because it would force us to configure Samba on the server side, set the various permissions and configuration options in Windows and place both machines on the same local network or configure complex rules on our firewall to allow SMB/CIFS traffic. And yet, the file transfer through the network would not be safe, because it would be made text clear with no encryption.
There exists a simpler solution consisting in leveraging the flexibility and security SSH provides and the simplicity and reliability of rsync to synchronize files across the network. Just need to set up an SSH server on your Windows computer and install the DeltaCopy Server software, which will serve as an rsync server.
DeltaCopy Server is set to listen on port 873 to serve requests for file synchronization in the same way the rsync daemon does.
We need to start it as a service running in the background via the main configuration console.
Finally, simply specify the virtual directories that contain the files you want to synchronize, wich will be the only visible ones from the rsync client. We have the ability to set these virtual directories as read-only to prevent them from being changed from outside and also to establish a username and password, but it won’t be necessary if we use SSH as authentication mechanism.
Command to run from the rsync client
Once you have everything set up on Windows only one thing would be to finish. Just run the appropriate command to synchronize the contents of the virtual directory on the client computer that will be responsible for performing backups, being 192.168.0.20 the Windows box, aeat the virtual directory and /var/data/backups/aeat the target directory where the synchronized files will be stored on the computer running rsync:
$ rsync -avz --delete-before 192.168.0.20::aeat /var/data/backups/aeat/
We can even use some more advanced solutions for backup like rsnapshot or rdiff-backup, since both operate on rsync.