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.
Just a fellow user here but... Isn't it worth it to you to spend 4KB of disk space and 1 inode to record that a backup happened and that no files were replaced or deleted during that backup?
It's request from not me only: http://unix.stackexchange.com/questions/150378/rsync-3-1-0-is-creating-empty-backup-directories?rq=1 I search for solution to fix it like other peoples...
With construction like: --backup-dir=/var/backups/www/old/`date +%F` I see backup dirs with changed files only. Rsync 3.1.x break this backup feature.
if rsync befor 3.1.0 created backup dir only when needed, i think the behaviour should be changed to the old one - it sounds reasonable what you tell.
*** This bug has been marked as a duplicate of bug 10724 ***
I misread this bug as a duplicate of 10724, which is talking about empty dirs down inside the top-level backup dir. Sorry about that. The newest rsync creates the top-level backup dir early so that the user gets some feedback if they didn't expect the dir to get created. It also ensures that rsync has a better idea if backups are going to succeed or not in total (a failure to find and/or make the backup dir causes the transfer to abort immediately). This change is as designed, and I'm not planning to change it. For your scripted backup use, you could follow an rsync run with: rmdir --ignore-fail-on-non-empty "$BACKUP_DIR" if you want to ensure that an empty dir is removed.
adsh@gw:~>mkdir test adsh@gw:~>rmdir --ignore-fail-on-non-empty test/ rmdir: illegal option -- - usage: rmdir [-pv] directory ... adsh@gw:~>uname -sr FreeBSD 9.3-RELEASE-p21 adsh@Launcher:~>mkdir test adsh@Launcher:~>rmdir --ignore-fail-on-non-empty test/ rmdir: unknown option -- - usage: rmdir [-p] directory ... adsh@Launcher:~>uname -sr OpenBSD 5.4 There are many other OS in the World besides Linux... Many peoples want use old program functionality, not dirty hack solution.
You simply may add program code to remove empty backup-dir after sync is done for compatibility with older versions.
While it is true that 'rmdir --ignore-fail-on-non-empty "$BACKUP_DIR"' is GNU (not Linux) specific it is also true that 'rmdir "$BACKUP_DIR" > /dev/null 2>&1' is POSIX specific. If you want even more compatibility here is the [t]csh version: rmdir "$BACKUP_DIR" >& /dev/null
There is example how to remove all garbage backup-dirs in FreBSD without pipes in one line: find /var/backups/www/old/ -type d -maxdepth 1 -empty -delete but all this solutions are dirty hacks, not well-established rsync functionality.
How is this resolved? The change in behaviour is a major PITA . . Phil.
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.