transferred files if the transfer is interrupted.
added a "options summary" section to the man page
STRUCT_STAT st;
extern int orig_umask;
+ if (verbose > 2)
+ rprintf(FINFO,"get_local_name count=%d %s\n",
+ flist->count, name);
+
if (do_stat(name,&st) == 0) {
if (S_ISDIR(st.st_mode)) {
if (!push_dir(name, 0)) {
int am_daemon=0;
int am_client=0;
int do_stats=0;
+int keep_partial=0;
int block_size=BLOCK_SIZE;
rprintf(F," --rsync-path=PATH specify path to rsync on the remote machine\n");
rprintf(F," -C, --cvs-exclude auto ignore files in the same way CVS does\n");
rprintf(F," --delete delete files that don't exist on the sending side\n");
+ rprintf(F," --partial keep partially transferred files\n");
rprintf(F," --force force deletion of directories even if not empty\n");
rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n");
rprintf(F," --timeout=TIME set IO timeout in seconds\n");
enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
OPT_EXCLUDE_FROM,OPT_DELETE,OPT_NUMERIC_IDS,OPT_RSYNC_PATH,
OPT_FORCE,OPT_TIMEOUT,OPT_DAEMON,OPT_CONFIG,OPT_PORT,
- OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS};
+ OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL};
static char *short_options = "oblLWHpguDCtcahvrRIxnSe:B:T:z";
{"compress", 0, 0, 'z'},
{"daemon", 0, 0, OPT_DAEMON},
{"stats", 0, 0, OPT_STATS},
+ {"partial", 0, 0, OPT_PARTIAL},
{"config", 1, 0, OPT_CONFIG},
{"port", 1, 0, OPT_PORT},
{0,0,0,0}};
do_stats = 1;
break;
+ case OPT_PARTIAL:
+ keep_partial = 1;
+ break;
+
case OPT_CONFIG:
config_file = optarg;
break;
if (delete_mode)
args[ac++] = "--delete";
+ if (keep_partial)
+ args[ac++] = "--partial";
+
if (force_delete)
args[ac++] = "--force";
}
static char *cleanup_fname;
+static char *cleanup_new_fname;
+static struct file_struct *cleanup_file;
+static void finish_transfer(char *fname, char *fnametmp, struct file_struct *file);
void exit_cleanup(int code)
{
+ extern int keep_partial;
+
+ if (cleanup_fname && keep_partial) {
+ finish_transfer(cleanup_new_fname, cleanup_fname, cleanup_file);
+ }
io_flush();
- if (cleanup_fname)
+ if (cleanup_fname && !keep_partial)
do_unlink(cleanup_fname);
signal(SIGUSR1, SIG_IGN);
if (code) {
return 1;
}
+/* finish off a file transfer, renaming the file and setting the permissions
+ and ownership */
+static void finish_transfer(char *fname, char *fnametmp, struct file_struct *file)
+{
+ if (make_backups) {
+ char fnamebak[MAXPATHLEN];
+ if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
+ rprintf(FERROR,"backup filename too long\n");
+ return;
+ }
+ slprintf(fnamebak,sizeof(fnamebak)-1,"%s%s",fname,backup_suffix);
+ if (do_rename(fname,fnamebak) != 0 && errno != ENOENT) {
+ rprintf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
+ return;
+ }
+ }
+
+ /* move tmp file over real file */
+ if (do_rename(fnametmp,fname) != 0) {
+ if (errno == EXDEV) {
+ /* rename failed on cross-filesystem link.
+ Copy the file instead. */
+ if (copy_file(fnametmp,fname, file->mode)) {
+ rprintf(FERROR,"copy %s -> %s : %s\n",
+ fnametmp,fname,strerror(errno));
+ } else {
+ set_perms(fname,file,NULL,0);
+ }
+ do_unlink(fnametmp);
+ } else {
+ rprintf(FERROR,"rename %s -> %s : %s\n",
+ fnametmp,fname,strerror(errno));
+ do_unlink(fnametmp);
+ }
+ } else {
+ set_perms(fname,file,NULL,0);
+ }
+}
+
+
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
{
int fd1,fd2;
}
while (1) {
+ cleanup_fname = NULL;
+ cleanup_new_fname = NULL;
+
i = read_int(f_in);
if (i == -1) {
if (phase==0 && remote_version >= 13) {
}
cleanup_fname = fnametmp;
+ cleanup_new_fname = fname;
+ cleanup_file = file;
if (!am_server && verbose)
printf("%s\n",fname);
if (verbose > 2)
rprintf(FINFO,"renaming %s to %s\n",fnametmp,fname);
-
- if (make_backups) {
- char fnamebak[MAXPATHLEN];
- if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
- rprintf(FERROR,"backup filename too long\n");
- continue;
- }
- slprintf(fnamebak,sizeof(fnamebak)-1,"%s%s",fname,backup_suffix);
- if (do_rename(fname,fnamebak) != 0 && errno != ENOENT) {
- rprintf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
- continue;
- }
- }
-
- /* move tmp file over real file */
- if (do_rename(fnametmp,fname) != 0) {
- if (errno == EXDEV) {
- /* rename failed on cross-filesystem link.
- Copy the file instead. */
- if (copy_file(fnametmp,fname, file->mode)) {
- rprintf(FERROR,"copy %s -> %s : %s\n",
- fnametmp,fname,strerror(errno));
- } else {
- set_perms(fname,file,NULL,0);
- }
- do_unlink(fnametmp);
- } else {
- rprintf(FERROR,"rename %s -> %s : %s\n",
- fnametmp,fname,strerror(errno));
- do_unlink(fnametmp);
- }
- } else {
- set_perms(fname,file,NULL,0);
- }
+ finish_transfer(fname, fnametmp, file);
+
cleanup_fname = NULL;
-
+ cleanup_new_fname = NULL;
+ cleanup_file = NULL;
if (!recv_ok) {
if (csum_length == SUM_LENGTH) {
this is launched from cron every few hours.
+manpagesection(OPTIONS SUMMARY)
+
+Here is a short summary of the options avalable in rsync. Please refer
+to the detailed description below for a complete description.
+
+verb(
+ -v, --verbose increase verbosity
+ -c, --checksum always checksum
+ -a, --archive archive mode
+ -r, --recursive recurse into directories
+ -R, --relative use relative path names
+ -b, --backup make backups (default ~ extension)
+ -u, --update update only (don't overwrite newer files)
+ -l, --links preserve soft links
+ -L, --copy-links treat soft links like regular files
+ -H, --hard-links preserve hard links
+ -p, --perms preserve permissions
+ -o, --owner preserve owner (root only)
+ -g, --group preserve group
+ -D, --devices preserve devices (root only)
+ -t, --times preserve times
+ -S, --sparse handle sparse files efficiently
+ -n, --dry-run show what would have been transferred
+ -W, --whole-file copy whole files, no incremental checks
+ -x, --one-file-system don't cross filesystem boundaries
+ -B, --block-size=SIZE checksum blocking size
+ -e, --rsh=COMMAND specify rsh replacement
+ --rsync-path=PATH specify path to rsync on the remote machine
+ -C, --cvs-exclude auto ignore files in the same way CVS does
+ --delete delete files that don't exist on the sending side
+ --partial keep partially transferred files
+ --force force deletion of directories even if not empty
+ --numeric-ids don't map uid/gid values by user/group name
+ --timeout=TIME set IO timeout in seconds
+ -I, --ignore-times don't exclude files that match length and time
+ -T --temp-dir=DIR create temporary files in directory DIR
+ -z, --compress compress file data
+ --exclude=PATTERN exclude file FILE
+ --exclude-from=PATTERN exclude files listed in FILE
+ --include=PATTERN don't exclude file FILE
+ --include-from=PATTERN don't exclude files listed in FILE
+ --suffix=SUFFIX override backup suffix
+ --version print version number
+ --daemon run as a rsync daemon
+ --config=FILE specify alternate rsyncd.conf file
+ --port=PORT specify alternate rsyncd port number
+ --stats give some file transfer stats
+ -h, --help show this help screen
+)
+
manpageoptions()
rsync uses the GNU long options package. Many of the command line
is not used and the whole file is sent as-is instead. This may be
useful when using rsync with a local machine.
+dit(bf(--partial)) By default rsync will delete any partially
+transferred file if the transfer is interrupted. In some circumstances
+it is more desirable to keep partially transferred files. Using the
+--partial option tells rsync to keep the partial file which should
+make a subsequent transfer of the rest of the file much faster.
+
dit(bf(-p, --perms)) This option causes rsync to update the remote
permissions to be the same as the local permissions.