Bug 11423 - rsync 3.1.x is creating empty backup directories
rsync 3.1.x is creating empty backup directories
Product: rsync
Classification: Unclassified
Component: core
All All
: P5 major
: ---
Assigned To: Wayne Davison
Rsync QA Contact
Depends on:
  Show dependency treegraph
Reported: 2015-08-01 02:28 UTC by adsh
Modified: 2015-08-24 05:10 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description adsh 2015-08-01 02:28:18 UTC
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.
Comment 1 Kevin Korb 2015-08-01 02:33:11 UTC
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?
Comment 2 adsh 2015-08-01 03:09:08 UTC
It's request from not me only:


I search for solution to fix it like other peoples...
Comment 3 adsh 2015-08-01 03:18:58 UTC
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.
Comment 4 roland 2015-08-01 14:34:04 UTC
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.
Comment 5 Wayne Davison 2015-08-02 17:17:33 UTC

*** This bug has been marked as a duplicate of bug 10724 ***
Comment 6 Wayne Davison 2015-08-13 22:40:44 UTC
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.
Comment 7 adsh 2015-08-17 01:11:43 UTC
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.
Comment 8 adsh 2015-08-17 01:31:12 UTC
You simply may add program code to remove empty backup-dir after sync is done for compatibility with older versions.
Comment 9 Kevin Korb 2015-08-17 03:12:11 UTC
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
Comment 10 adsh 2015-08-17 03:48:01 UTC
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.
Comment 11 Philip Rhoades 2015-08-23 20:35:40 UTC
How is this resolved? The change in behaviour is a major PITA  . .

Comment 12 Wayne Davison 2015-08-24 05:10:30 UTC
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.