[PATCH] (Resubmission) Enable push to remote rsynced server using
rsync:// URL
Mike Fleetwood
mike at rockover.demon.co.uk
Sat Jul 20 09:39:01 EST 2002
Hello,
Recently I noticed a disparity in the use of HOST::MODULE and
rsync://HOST/MODULE syntax by rsync. HOST::MODULE can be used to both
pull from and push to a remote rsyncd server, but rsync://HOST/MODULE
can only be used to pull from a remote rsyncd server. The attached
patch resolves this issue by also allowing a rsync:// URL to be used
to push files to a remote rsyncd server.
Testing: Some. Caveat Emptor!
I use it internally at work to replicate a few directory trees between
2 Compaq Tru64 UNIX boxes; pushing to a remote rsyncd server using a
rsync:// URL.
Grateful Rsync user,
Mike
--
__ __ _ _ ___ ____ _ ___ ___ _ ___ ___ _
| \/ (_| | _ / _ \ | ___| | / _ \/ _ \| |_ _ _ _/ \/ \ _| |
| |\/| | | |/ | ___| | _| | |_| __| ___| __| \/ \/| O | O / _ |
|_| |_|_|_|\_\\___| |_| |____\___|\___||____\_/^\_/\___/\___/\___|
-------------- next part --------------
diff -urN rsync-2.5.5/main.c rsync-2.5.5+pushURL/main.c
--- rsync-2.5.5/main.c Wed Mar 27 05:10:44 2002
+++ rsync-2.5.5+pushURL/main.c Wed Jun 5 09:15:44 2002
@@ -673,6 +673,8 @@
if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) == 0) {
char *host, *path;
+ /* First parameter is rsync://HOST/MODULE URL.
+ * Receive from remote rsyncd server. */
host = argv[0] + strlen(URL_PREFIX);
p = strchr(host,'/');
@@ -695,6 +697,8 @@
if (p) {
if (p[1] == ':') { /* double colon */
+ /* First parameter is HOST::MODULE.
+ * Receive from remote rsyncd server. */
*p = 0;
return start_socket_client(argv[0], p+2, argc-1, argv+1);
}
@@ -704,6 +708,8 @@
exit_cleanup(RERR_SYNTAX);
}
+ /* First parameter is HOST:MODULE.
+ * Receive from remote shell. */
am_sender = 0;
*p = 0;
shell_machine = argv[0];
@@ -713,10 +719,34 @@
} else {
am_sender = 1;
+ if (strncasecmp(URL_PREFIX, argv[argc-1], strlen(URL_PREFIX)) == 0) {
+ char *host, *path;
+ /* Last parameter is rsync://HOST/MODULE.
+ * Send to remote rsyncd server. */
+
+ host = argv[argc-1] + strlen(URL_PREFIX);
+ p = strchr(host,'/');
+ if (p) {
+ *p = 0;
+ path = p+1;
+ } else {
+ path="";
+ }
+ p = strchr(host,':');
+ if (p) {
+ rsync_port = atoi(p+1);
+ *p = 0;
+ }
+ return start_socket_client(host, path, argc-1, argv);
+ }
+
p = find_colon(argv[argc-1]);
if (!p) {
+ /* Local copy. */
local_server = 1;
} else if (p[1] == ':') {
+ /* Last paramter is HOST::MODULE.
+ * Send to remote rsyncd server. */
*p = 0;
return start_socket_client(argv[argc-1], p+2, argc-1, argv);
}
@@ -726,6 +756,8 @@
exit_cleanup(RERR_SYNTAX);
}
+ /* Last parameter is HOST:MODULE.
+ * Send to remote shell. */
if (local_server) {
shell_machine = NULL;
shell_path = argv[argc-1];
diff -urN rsync-2.5.5/options.c rsync-2.5.5+pushURL/options.c
--- rsync-2.5.5/options.c Tue Mar 19 20:16:42 2002
+++ rsync-2.5.5+pushURL/options.c Wed Jun 5 09:17:13 2002
@@ -196,6 +196,7 @@
rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");
rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");
+ rprintf(F," or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n");
rprintf(F,"SRC on single-colon remote HOST will be expanded by remote shell\n");
rprintf(F,"SRC on server remote HOST may contain shell wildcards or multiple\n");
rprintf(F," sources separated by space as long as they have same top-level\n");
diff -urN rsync-2.5.5/rsync.1 rsync-2.5.5+pushURL/rsync.1
--- rsync-2.5.5/rsync.1 Wed Feb 6 21:21:19 2002
+++ rsync-2.5.5+pushURL/rsync.1 Wed Jun 5 09:19:54 2002
@@ -15,6 +15,8 @@
.PP
rsync [OPTION]\&.\&.\&. rsync://[USER@]HOST[:PORT]/SRC [DEST]
.PP
+rsync [OPTION]\&.\&.\&. SRC [SRC]\&.\&.\&. rsync://[USER@]HOST[:PORT]/DEST
+.PP
.SH "DESCRIPTION"
.PP
rsync is a program that behaves in much the same way that rcp does,
@@ -72,7 +74,7 @@
.IP o
for copying from the local machine to a remote rsync
server\&. This is invoked when the destination path contains a ::
-separator\&.
+separator or a rsync:// URL\&.
.IP
.IP o
for listing files on a remote machine\&. This is done the
@@ -165,7 +167,7 @@
.PP
.IP o
you use a double colon :: instead of a single colon to
-separate the hostname from the path\&.
+separate the hostname from the path or a rsync:// URL\&.
.IP
.IP o
the remote server may print a message of the day when you
More information about the rsync
mailing list