Modifications to NOT recursively make_backup
Mike Bombich
mike at bombich.com
Tue Apr 3 18:44:12 GMT 2007
Hi:
Suppose I have the following files on my target volume:
/Applications/[45,000 sub files and directories]
/Developer/[120,000 sub files and directories]
... (another 8 or so directories with lots of files and sub directories)
/usr/ [75,000 sub files and directories]
For a total of approximately 500K files and directories. On my
source, I have only a handful of items:
/Data/ [70 items]
/Records/ [20 items]
/Finances/ [45 items]
Now I want to copy source to target, while archiving what is already
on the target:
rsync -a --backup --backup-dir="backup_2007_04_03_14-03-34" --delete /
Volumes/Source/ /Volumes/Target
The result is that it takes an incredibly long time to move
essentially everything on the target -- one at a time -- to the
backup directory on the target. Instead of recognizing that each of
the 11 root items on the target do not exist on the source, rsync
does a depth-first backup and thus performs 500K mv operations.
My questions is why? I made the following modifications to
generator.c and backup.c (2.6.6) which eliminates the depth-first
backup and immediately backs up the root items, but I'm wondering if
there was a specific reason to do a depth-first backup instead, and
if my changes will have an adverse or unexpected result. In my
testing, it appears to be OK, but the code I'm replacing looks very
deliberate.
Thanks,
Mike
*** rsync 2.6.6/generator.c Mon Mar 12 21:04:28 2007
--- rsync 2.6.6+/generator.c Mon Apr 2 19:21:09 2007
*************** static int delete_item(char *fname, int
*** 190,197 ****
|| (dry_run && zap_dir)) {
ok = 0;
errno = ENOTEMPTY;
! } else if (make_backups && !backup_dir && !is_backup_file(fname)
- && !(flags & DEL_FORCE_RECURSE))
ok = make_backup(fname);
else
ok = do_rmdir(fname) == 0;
--- 190,198 ----
|| (dry_run && zap_dir)) {
ok = 0;
errno = ENOTEMPTY;
! } else if (make_backups)
ok = make_backup(fname);
else
ok = do_rmdir(fname) == 0;
*** rsync 2.6.6/backup.c Sun Mar 25 20:57:48 2007
--- rsync 2.6.6+/backup.c Tue Apr 3 13:15:32 2007
*************** static int keep_backup(char *fname)
*** 204,222 ****
}
if (!kept && S_ISDIR(file->mode)) {
! /* make an empty directory */
! if (do_mkdir(buf, file->mode) < 0
! && (errno != ENOENT || make_bak_dir(buf) < 0
! || do_mkdir(buf, file->mode) < 0)) {
! rsyserr(FINFO, errno, "mkdir %s failed",
! full_fname(buf));
}
- ret_code = do_rmdir(fname);
- if (verbose > 2) {
- rprintf(FINFO, "make_backup: RMDIR %s returns
%i\n",
- full_fname(fname), ret_code);
- }
kept = 1;
}
--- 204,214 ----
}
if (!kept && S_ISDIR(file->mode)) {
! if (robust_move(fname, buf) != 0) {
! rsyserr(FERROR, errno, "keep_backup failed: %
s -> \"%s\"",
! full_fname(fname), safe_fname(buf));
}
kept = 1;
}
More information about the rsync
mailing list