Rsync 3.1.0 is creating empty backup directories

rsync

I just noticed that there is a discrepancy between version 3.0.9 and 3.1.0 of rsync.

Running the command

$ rsync -a --delete --backup --backup-dir=../old source/ dest/

with version 3.1.0 gives the output

Created backup_dir ../old/

even when no files are copied to the backup directory. I usually add the current time to the backup directory name, which means I end up with many empty directories. With version 3.0.9 of rsync, a backup directory was only created if needed.

My questions are:

  1. Is this an intended behaviour, and if so, is it possible to suppress the creation of empty backup directories?
  2. Can I install version 3.0.9 of rsync alongside with version 3.1.0 such that one is called say rsync309 and the other one rsync310, and then have an alias linking rsync to either of the two (which in my case means that I would keep using rsync 3.0.9 as I found this new behaviour annoying)?

Best Answer

Yes, this was intended behavior. Bug no 11423 was filed about it, and it was changed back in version 3.1.2.

https://bugzilla.samba.org/show_bug.cgi?id=11423#c12 :

While I continue to like the new early verification of the top-level backup dir at the start of the transfer, I've been persuaded to have it go back to not creating the directory until it is needed. Fixed for upcoming 3.1.2 release.

While most distributions don't provide packages for version 3.1.2 yet, it is really quick and easy to compile: I did the following on Debian Jessie, and it went fine, installing the new version into /usr/local/bin:

wget https://download.samba.org/pub/rsync/src/rsync-3.1.2.tar.gz
tar xvf rsync-3.1.2.tar.gz -C /tmp/
cd /tmp/rsync-3.1.2/
./configure
make
make install

If you use it as a daemon, your init script may call it by it's full path, so you may also want to replace it with a link to the new version:

/etc/init.d/rsync stop
mv /usr/bin/rsync /usr/bin/rsync.old
ln -si ../local/bin/rsync /usr/bin/rsync
/etc/init.d/rsync start

Update: If you are on Debian Jessie, you can actually just install the rsync package from Debian Stretch :

wget "http://ftp.ch.debian.org/debian/pool/main/r/rsync/rsync_3.1.2-1_amd64.deb"
dpkg -i rsync_3.1.2-1_amd64.deb
Related Question