permissions bug w/ --backup-dir or --backup option?

James Delahanty jimd at gie.com
Thu Sep 20 23:51:14 EST 2001


Carey,

What you are seeing is, in fact, the case, but the function that creates
the dirs is robust_move() in backup.c

The backup option captures files and/or directories that are deleted or
changed between syncs.  So, if a directory is *changed*
(deleted/renamed/moved), then the directory *and* it's permissions are
copied over.  If a file (node, etc.) is changed, then the file and it's
permissions are carried over.  If a directory is created by rsync simply
to position a changed file, then no permissions are carried over to that
directory (they are explicitly created 0755 by robust_move()).  

This works great for us, because 1) it's faster, and 2) we really don't
care about the directory permissions/owners unless the directory is
changed directly by a move/rename/delete.  That said, you do have a
point.  (And, just because I don't use it, doesn't mean it's not right
:^)

Add one line to backup.c to do your thing.  There will be a little
overhead, but it will work they way you want it to work, and smack 
permissions on all directories on the backup-dir path leading to the
changed file(s).

** This patch works with both 2.4.6 and 2.4.7pre1 -- jmd          **
** Don't forget to convert CR/LF (Dos Format) to LF (Unix Format) **
** before patching.  Edit to remove line wraps, as well.          **
-------------- Cut here ----------------
*** backup.c.orig	Sat Aug 19 08:10:39 2000
--- backup.c	Thu Sep 20 08:17:19 2001
***************
*** 266,271 ****
--- 266,272 ----
  
  	/* move to keep tree if a file */
  	if(!kept) {
+ 		make_bak_dir(fname,backup_dir);	/* Set up permissions for path - jmd
*/
  		if (!robust_move (fname, keep_name))
  			rprintf(FERROR, "keep_backup failed %s -> %s : %s\n",
  				fname, keep_name, strerror(errno));
-------------- Cut here ----------------

Good suggestion, Carey!


Jim Delahanty
jimd at gie.com


Carey Jung wrote:
> 
> James,
> 
> I think the problem with --backup-dir lies in make_bak_dir in backup.c.
> >From what I can tell by looking at the code, as it builds the backup
> directory path, it's not setting mod times, ownership, and permissions on
> the backed up directories, just on the backed up file.  Make sense?
> 
> Carey
>




More information about the rsync mailing list