Running rsync 2.4.7pre1, using the --backup-dir option, I just realized today that file ownerships and permissions of backed up files are not preserved. In other words, if rsync moves an obsolete file to the backup dir, it's ownership seems to revert to root:root, and permissions change, as well. We are also using the -a (archive) option, by the way, which should mean "preserve everything". This loss of ownership/permissions seems like a definite bug to me. What do you think? Regards, Carey Jung IT Freedom
By the way, if it makes a difference, our backup-dir is on a different partition than the destination directory. I'm not sure if --backup permissions/ownership are preserved properly if done on the same partition. Carey> -----Original Message----- > From: rsync-admin@lists.samba.org [mailto:rsync-admin@lists.samba.org]On > Behalf Of Carey Jung > Sent: Wednesday, September 19, 2001 12:38 AM > To: rsync list > Subject: permissions bug w/ --backup-dir or --backup option? > > > Running rsync 2.4.7pre1, using the --backup-dir option, I just realized > today that file ownerships and permissions of backed up files are not > preserved. In other words, if rsync moves an obsolete file to the backup > dir, it's ownership seems to revert to root:root, and permissions > change, as > well. We are also using the -a (archive) option, by the way, which should > mean "preserve everything". This loss of ownership/permissions > seems like a > definite bug to me. What do you think? > > Regards, > Carey Jung > IT Freedom > > > >
Carey, Well, I'm not sure what platform/filesystem you're running on, but we use rsync on linux (ext2fs) with the --backup-dir and -a options, backing files up to a different volume on the same machine, and don't have the problem you describe. The backup partition is natively mounted (not NFS, or SMB, or whatever). I've looked at the code for backup-dir (okay, actually, I *wrote* the code for backup-dir :^) If rsync *can* set the permissions on the file(s), it will. Examine the code in backup.c and set_perms() in rsync.c. It looks pretty solid to me, and has really worked well for us. A typical (for us) run is executed like this: rsync -abHS --backup-dir=/mnt/backup/spud spud.gie.com::a /mnt/spud/a/ And we've done 19,658 runs so far (8/server/day), over 380 Gigs sync'd with an average of 44Meg(11Meg compressed) of data per run, and all of our backup files come across with correct owners and permissions. Whew! I'd look to your filesystem first. Do the rsync'd files (not backup-dir files) come across with the right permissions? Jim Delahanty jimd@gie.com> From: "Carey Jung" <carey@itfreedom.com> > To: "rsync list" <rsync@lists.samba.org> > Subject: RE: permissions bug w/ --backup-dir or --backup option? > Date: Wed, 19 Sep 2001 00:41:17 -0500 > > By the way, if it makes a difference, our backup-dir is on a different > partition than the destination directory. I'm not sure if --backup > permissions/ownership are preserved properly if done on the same partition. > > Carey > > > -----Original Message----- > > From: rsync-admin@lists.samba.org [mailto:rsync-admin@lists.samba.org]On > > Behalf Of Carey Jung > > Sent: Wednesday, September 19, 2001 12:38 AM > > To: rsync list > > Subject: permissions bug w/ --backup-dir or --backup option? > > > > > > Running rsync 2.4.7pre1, using the --backup-dir option, I just realized > > today that file ownerships and permissions of backed up files are not > > preserved. In other words, if rsync moves an obsolete file to the backup > > dir, it's ownership seems to revert to root:root, and permissions > > change, as > > well. We are also using the -a (archive) option, by the way, which should > > mean "preserve everything". This loss of ownership/permissions > > seems like a > > definite bug to me. What do you think? > > > > Regards, > > Carey Jung > > IT Freedom > >
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@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 >