-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hy folks,
everybody knows, that rsync eats up a lot of memory, when rsyncing
a lot of files.
To avoid this i run rsync on different parts of the directory-tree
(e.g. first ~muchofileuser/muchofilesdir1 then
~muchofileuser/muchofilesdir2 and so on) and it works fine for me.
So i tried to do this in a automatical way (e.g perl/shell/whatever
script) but rsync is missing one feature for that:
Limit the depth of recursion in "recursive"-Mode.
So i wrote this ugly patch, that works-for-me(TM):
diff -uNr rsync-2.5.6/flist.c rsync-2.5.6-patched/flist.c
- --- rsync-2.5.6/flist.c Sat Jan 18 19:00:23 2003
+++ rsync-2.5.6-patched/flist.c Mon Jun 23 21:38:21 2003
@@ -41,6 +41,7 @@
extern int cvs_exclude;
extern int recurse;
+extern int recurse_level;
extern int one_file_system;
extern int make_backups;
@@ -797,11 +798,20 @@
send_file_entry(file, f, base_flags);
}
- - if (S_ISDIR(file->mode) && recursive) {
+ if (S_ISDIR(file->mode) && recursive ) {
struct exclude_struct **last_exclude_list
local_exclude_list;
- - send_directory(f, flist, f_name(file));
- - local_exclude_list = last_exclude_list;
+
+ if ( recurse_level>1 || !recurse_level) {
+ if (recurse_level)
+ recurse_level--;
+
+ send_directory(f, flist, f_name(file));
+ local_exclude_list = last_exclude_list;
+
+ if (recurse_level)
+ recurse_level++;
+ }
return;
}
}
diff -uNr rsync-2.5.6/options.c rsync-2.5.6-patched/options.c
- --- rsync-2.5.6/options.c Tue Jan 28 04:11:57 2003
+++ rsync-2.5.6-patched/options.c Mon Jun 23 21:13:19 2003
@@ -66,6 +66,7 @@
int am_server = 0;
int am_sender = 0;
int recurse = 0;
+int recurse_level = 0;
int am_daemon = 0;
int daemon_over_rsh = 0;
int do_stats=0;
@@ -209,6 +210,7 @@
rprintf(F," -c, --checksum always checksum\n");
rprintf(F," -a, --archive archive mode, equivalent to
- -rlptgoD\n");
rprintf(F," -r, --recursive recurse into
directories\n");
+ rprintf(F," -N --recursive-level maximum depth of
recursion\n");
rprintf(F," -R, --relative use relative path
names\n");
rprintf(F," -b, --backup make backups (default %s
suffix)\n",BACKUP_SUFFIX);
rprintf(F," --backup-dir make backups into this
directory\n");
@@ -338,6 +340,7 @@
{"server", 0, POPT_ARG_NONE, &am_server , 0, 0, 0
},
{"sender", 0, POPT_ARG_NONE, 0,
OPT_SENDER, 0, 0
},
{"recursive", 'r', POPT_ARG_NONE, &recurse , 0,
0, 0 },
+ {"recursive-level", 'N', POPT_ARG_INT,
&recurse_level, 0, 0, 0 },
{"relative", 'R', POPT_ARG_NONE,
&relative_paths , 0, 0, 0 },
{"rsh", 'e', POPT_ARG_STRING, &shell_cmd ,
0, 0, 0 },
{"block-size", 'B', POPT_ARG_INT, &block_size ,
0, 0, 0 },
@@ -658,6 +661,7 @@
static char mdelete[30];
static char mwindow[30];
static char bw[50];
+ static char rlevel[50];
/* Leave room for ``--(write|read)-batch='' */
static char fext[MAXPATHLEN + 15];
@@ -741,6 +745,12 @@
argstr[x] = 0;
if (x != 1) args[ac++] = argstr;
+
+ if (recurse_level) {
+ snprintf(rlevel,sizeof(rlevel),"-N%d",recurse_level);
+ args[ac++] = rlevel;
+ }
+
if (block_size != BLOCK_SIZE) {
snprintf(bsize,sizeof(bsize),"-B%d",block_size);
If you think this patch is worth being fixed and rewritten
in a better way, so do it and apply it to the current CVS-tree of rsync.
Thanks.
Richard Mueller
- --
Richard M?ller Mail: mueller@teamix.net
Technik Tel: +49 (911) 30999-0
Team(ix) GmbH Fax: +49 (911) 30999-99
S?d-West-Park 35, 90449 N?rnberg, Deutschland GPG: 0xF9F18FF7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE+913h+nPs3Pnxj/cRAq4GAJ9ahgAZv7Ek6iNjs6Qr482CiG6UVwCfZp4D
70P4qL2bRaQKK1Xp+OCVo/E=E4u5
-----END PGP SIGNATURE-----