| 1 | Greetings, and thanks for all of your work on the wonderful rsync! |
| 2 | |
| 3 | I recently had the need to transfer files only with different mod |
| 4 | dates (and to *not* transfer them based on file size differences). |
| 5 | This is because I'm backing up files remotely on an untrusted machine, |
| 6 | so I'm encrypting them with gpg before transfer. I discovered that |
| 7 | rsync didn't already have a --date-only flag, so I added one and am |
| 8 | enclosing the diffs in case you (as I hope) decide to include this |
| 9 | option in future releases. |
| 10 | |
| 11 | Again, thanks! |
| 12 | |
| 13 | Best Regards, |
| 14 | Jeremy Bornstein |
| 15 | |
| 16 | [Patched update to have context and apply to latest CVS source.] |
| 17 | |
| 18 | --- generator.c 18 May 2004 08:50:17 -0000 1.85 |
| 19 | +++ generator.c 18 May 2004 09:31:22 -0000 |
| 20 | @@ -51,6 +51,7 @@ extern int list_only; |
| 21 | extern int only_existing; |
| 22 | extern int orig_umask; |
| 23 | extern int safe_symlinks; |
| 24 | +extern int date_only; |
| 25 | |
| 26 | extern struct exclude_list_struct server_exclude_list; |
| 27 | |
| 28 | @@ -58,6 +59,8 @@ extern struct exclude_list_struct server |
| 29 | /* choose whether to skip a particular file */ |
| 30 | static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st) |
| 31 | { |
| 32 | + if (date_only) |
| 33 | + return cmp_modtime(st->st_mtime,file->modtime) == 0; |
| 34 | if (st->st_size != file->length) { |
| 35 | return 0; |
| 36 | } |
| 37 | --- options.c 6 May 2004 21:08:01 -0000 1.148 |
| 38 | +++ options.c 18 May 2004 09:31:23 -0000 |
| 39 | @@ -82,6 +82,7 @@ int keep_partial = 0; |
| 40 | int safe_symlinks = 0; |
| 41 | int copy_unsafe_links = 0; |
| 42 | int size_only = 0; |
| 43 | +int date_only = 0; |
| 44 | int bwlimit = 0; |
| 45 | int delete_after = 0; |
| 46 | int only_existing = 0; |
| 47 | @@ -262,6 +263,7 @@ void usage(enum logcode F) |
| 48 | rprintf(F," --timeout=TIME set I/O timeout in seconds\n"); |
| 49 | rprintf(F," -I, --ignore-times turn off mod time & file size quick check\n"); |
| 50 | rprintf(F," --size-only ignore mod time for quick check (use size)\n"); |
| 51 | + rprintf(F," --date-only ignore size for quick check (use mod time)\n"); |
| 52 | rprintf(F," --modify-window=NUM compare mod times with reduced accuracy\n"); |
| 53 | rprintf(F," -T --temp-dir=DIR create temporary files in directory DIR\n"); |
| 54 | rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n"); |
| 55 | @@ -316,6 +318,7 @@ static struct poptOption long_options[] |
| 56 | {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 }, |
| 57 | {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 }, |
| 58 | {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 }, |
| 59 | + {"date-only", 0, POPT_ARG_NONE, &date_only, 0, 0, 0 }, |
| 60 | {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, |
| 61 | {"one-file-system", 'x', POPT_ARG_NONE, &one_file_system, 0, 0, 0 }, |
| 62 | {"delete", 0, POPT_ARG_NONE, &delete_mode, 0, 0, 0 }, |
| 63 | @@ -905,6 +908,9 @@ void server_options(char **args,int *arg |
| 64 | |
| 65 | if (size_only) |
| 66 | args[ac++] = "--size-only"; |
| 67 | + |
| 68 | + if (date_only) |
| 69 | + args[ac++] = "--date-only"; |
| 70 | |
| 71 | if (modify_window_set) { |
| 72 | if (asprintf(&arg, "--modify-window=%d", modify_window) < 0) |
| 73 | --- rsync.yo 7 May 2004 00:18:37 -0000 1.169 |
| 74 | +++ rsync.yo 18 May 2004 09:31:23 -0000 |
| 75 | @@ -320,6 +320,7 @@ verb( |
| 76 | --timeout=TIME set I/O timeout in seconds |
| 77 | -I, --ignore-times turn off mod time & file size quick check |
| 78 | --size-only ignore mod time for quick check (use size) |
| 79 | + --date-only ignore size for quick check (use mod time) |
| 80 | --modify-window=NUM compare mod times with reduced accuracy |
| 81 | -T --temp-dir=DIR create temporary files in directory DIR |
| 82 | --compare-dest=DIR also compare received files relative to DIR |
| 83 | @@ -392,6 +393,12 @@ already the same size and have the same |
| 84 | regardless of timestamp. This is useful when starting to use rsync |
| 85 | after using another mirroring system which may not preserve timestamps |
| 86 | exactly. |
| 87 | + |
| 88 | +dit(bf(--date-only)) Normally rsync will skip any files that are |
| 89 | +already the same size and have the same modification time-stamp. With the |
| 90 | +--date-only option, files will be skipped if they have the same |
| 91 | +timestamp, regardless of size. This may be useful when the remote |
| 92 | +files have passed through a size-changing filter, e.g. for encryption. |
| 93 | |
| 94 | dit(bf(--modify-window)) When comparing two timestamps rsync treats |
| 95 | the timestamps as being equal if they are within the value of |