Efficient backup from windows to linux via rsync

written by Admin


Posted on 2013-08-06


Problem

I want to backup efficiently (incremental backup) a windows box via rsync on a linux box.

Solution

First install Cygwin on the windows box (don't forget to check rsync and ssh during installation) and check if rsync is installed on the linux box; if not, install it using APT (or the package manager of your distribution) and create a repository: add in /etc/rsyncd.cont a block like this (don't forget to adapt some parameters to reflect your configuration):
[repository_name]
   path = /home/backup/repository_name
   uid = nobody
   gid = nogroup
   read only = no
   use chroot = yes
   list = yes
   auth users = username
   secrets file = /etc/rsyncd.secrets

Then - again on the linux machine - add username and password in the file /etc/rsyncd.secrets using this format:
username:password
username2:password2
username3:password3
[..]
usernameN:passwordN

On the windows box create a text file and put into that file only the password of the rsync repository in the linux box.

Put this line in a .bat file and schedule the nightly execution (control panel - scheduled tasks):
C:\path\of\rsync -a -v --delete --password-file=C:\path\to\password.txt /cygdrive/c/source_dir rsync://username@ip_address/repository_name

On some system you need to put the rsync (cygwin) directory in the PATH environment variabile (My Computer - Properties - Advanced - Environment Variables).

Feedback


Comments

Leave a Comment:

Search

Welcome

We need collaboration and a real boost from our community: write us an email for every trick you find!

This website is a sysadmin swiss-knife for every-day Windows, Linux and Mac administration and troubleshooting

Our database grows if YOU send us your tips and trick as soon as you find them every day!