when using --backup-dir: why not make_bak_dir() . . .

James Delahanty jimd at gie.com
Mon Dec 16 22:02:00 EST 2002


You have a good point about make_bak_dir(), and pose a good question...

With the --backup-dir switch, any file *or directory* that is destined
for deletion is saved to the backup directory.  A file is "deleted" by
rsync whenever it is actually deleted on the sync system (obviously!),
or when it is replaced by a file with the same name/different rsync
signature as part of the rsync process.  All files or directories that
fall under this umbrella are saved to the backup-dir with their original
permissions intact.

The interesting question is: What do we do with directories that we must
manufacture to position the files in the "right" place in the

My take was: Completely ignore the permissions of these directories,
unless they were "deleted" (see above), and use the robust_move()
function already in backup.c to move the file/create the directories as
needed (perms: 0755).  This was done strictly for speed.  The win: Fast,
no hassle path creation.  The lose: Created path does NOT have same
permission as original path to file -- but the individual file
permissions are correct.  This was an acceptable tradeoff for our
purposes, but YMMV.  I can certainly understand (and appreciate) that
it's an unacceptable tradeoff to some.

Personally, I prefer that this shortcut be left as is, or be (yet
another) compile-time option. (-DKEEP_ALL_BK_DIR_PERMS), but I'm not a
maintainer, just a contributor.  (You might like to profile the change,
though, just to see the kind of hit you take.  IIRC, it was pretty

P.S. -- Many thanks to the Rsync team, Merry Christmas and Happy


Jim Delahanty

> Date: Mon, 9 Dec 2002 17:13:15 -0500
> From: Buck Huppmann <buckh at pobox.com>
> To: rsync at lists.samba.org
> Subject: when using --backup-dir: why not make_bak_dir() . . .
> here (in keep_backup())?
> --- backup.c.orig       Mon Dec  9 17:02:36 2002
> +++ backup.c    Mon Dec  9 17:03:50 2002
> @@ -273,6 +273,7 @@
>         /* move to keep tree if a file */
>         if(!kept) {
> +               make_bak_dir(fname,backup_dir);
>                 if (!robust_move (fname, keep_name))
>                         rprintf(FERROR, "keep_backup failed %s -> %s : %s\n",
>                                 fname, keep_name, strerror(errno));
> this reconstructs parent directory permissions more in keeping with
> my (humble) expectations, in addition to being consistent with the
> way all ~S_IFREG links' parents are produced
> just curious

More information about the rsync mailing list