Setting up Rsync
I was getting fed up with having to synchronize several folders containing photos. So I was looking for a good way to synchronize these images across the network. I first tried to put the images into Subversion but this turned out to be overkill. So that’s why I put my focus on Rsync.
Rsync has support for incremental file exchange. Not that I am going to use it but it still is cool. I will only use Rsync to keep my photo directories synched with the server. So lets install it.
apt-get install rsyncEdit the rsyncd.conf file in the /etc directory and create some entries here. Example is my photos entry here.
#/etc/rsyncd.conf #file containing username+passwords in the form <name>: <password> the file should be readable only BY user OR GROUP. #so chmod 660 or 600 would be necessary. secrets file = /etc/rsyncd.secrets motd file = /etc/rsyncd.motd #Below are actually defaults, but to be on the safe side... READ only = yes list = yes # with what user permissions should rsync handle directories? uid = nobody #gid = nobody #On debian group nobody is mapped to nogroup gid = nogroup #if stricts mode is true secrets file should not be readable by all. To disable this turn stricts mode to off. (built in for cygwin users) strict modes = true [photos] comment = Family Photos path = /share/photos auth users = wytze,wytske READ only = no hosts allow = 192.168.* hosts deny = * list = false </password></name>
Start the rsync daemon:
rsync --daemonNow you can start synchronizing. Synchronizing works like copying files with scp. So it’s fairly straightforward.
To retrieve a list of entries if listing is enabled:
rsync -avz wytze@debian::To synchronize files from server:
rsync -avz wytze@debian::photos /opt/my-local-photos
To synchronize files to the server:
rsync -avz /opt/my-local-photos/ wytze@debian::photos
Please mind the trailing slashes. Try out the difference with and without the trailing slash. Pretty straightforward there.