diff --git a/generator.c b/generator.c index b56fa569a..91bb6f4d4 100644 --- a/generator.c +++ b/generator.c @@ -68,6 +68,7 @@ extern int make_backups; extern int csum_length; extern int ignore_times; extern int size_only; +extern int time_only; extern OFF_T max_size; extern OFF_T min_size; extern int io_error; @@ -618,7 +619,7 @@ int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file { switch (ftype) { case FT_REG: - if (st->st_size != F_LENGTH(file)) + if (!time_only && st->st_size != F_LENGTH(file)) return 0; /* If always_checksum is set then we use the checksum instead diff --git a/options.c b/options.c index 578507c6e..7ef99f9cb 100644 --- a/options.c +++ b/options.c @@ -119,6 +119,7 @@ int safe_symlinks = 0; int copy_unsafe_links = 0; int munge_symlinks = 0; int size_only = 0; +int time_only = 0; int daemon_bwlimit = 0; int bwlimit = 0; int fuzzy_basis = 0; @@ -689,6 +690,7 @@ static struct poptOption long_options[] = { {"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 }, {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 }, {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 }, + {"time-only", 0, POPT_ARG_NONE, &time_only, 0, 0, 0 }, {"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 }, {"no-one-file-system",0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 }, {"no-x", 0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 }, @@ -2835,6 +2837,16 @@ void server_options(char **args, int *argc_p) args[ac++] = "--super"; if (size_only) args[ac++] = "--size-only"; + /* We don't send --time-only to server because: + * 1. sensible use of the --time-only option requires + * post-processing not done by rsync: compressing transferred + * files and truncating the original while preserving the timestamp. + * 2. older servers would croak. + * It may be a good idea to throw an error with a better error + * message... + */ + // if (time_only) + // args[ac++] = "--time-only"; if (do_stats) args[ac++] = "--stats"; } else { diff --git a/rsync.1.md b/rsync.1.md index 7e40e3617..c7be9fad8 100644 --- a/rsync.1.md +++ b/rsync.1.md @@ -504,6 +504,7 @@ has its own detailed description later in this manpage. --contimeout=SECONDS set daemon connection timeout in seconds --ignore-times, -I don't skip files that match size and time --size-only skip files that match in size +--time-only skip files that match in time (PULL ONLY) --modify-window=NUM, -@ set the accuracy for mod-time comparisons --temp-dir=DIR, -T create temporary files in directory DIR --fuzzy, -y find similar file for basis if no dest file @@ -776,6 +777,19 @@ expand it. after using another mirroring system which may not preserve timestamps exactly. +0. `--time-only` + + This modifies rsync's "quick check" algorithm for finding files that need + to be transferred, changing it from the default of transferring files with + either a changed size or a changed last-modified time to just looking for + files that have a changed last-modified time, ignoring size changes. This + is useful when remote files are uncompressed but a local copy should be + stored compressed, together with a zero-size stub to prevent re-transfers. + This option is only useful when pulling files, as it requires post-transfer + compression and truncation of files whilst preserving the original + modification time of the stub. Thus the option is not transmitted to the + remote side, also preventing the server from croaking on an unknown option. + 0. `--modify-window=NUM`, `-@` When comparing two timestamps, rsync treats the timestamps as being equal @@ -1031,7 +1045,8 @@ expand it. This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it - will be updated if the sizes are different.) + will be updated if the sizes are different - unless the --time-only flag + is set.) Note that this does not affect the copying of dirs, symlinks, or other special files. Also, a difference of file format between the sender and