1 Jeremy Bornstein wrote:
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.
11 To use this patch, run these commands for a successful build:
13 patch -p1 <patches/date-only.diff
14 ./configure (optional if already run)
17 based-on: 55b2a06812e39f15f52e92b979600cb82be210cb
18 diff --git a/generator.c b/generator.c
21 @@ -67,6 +67,7 @@ extern int append_mode;
22 extern int make_backups;
23 extern int csum_length;
24 extern int ignore_times;
25 +extern int date_only;
27 extern OFF_T max_size;
28 extern OFF_T min_size;
29 @@ -621,6 +622,9 @@ int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file
30 if (st->st_size != F_LENGTH(file))
34 + return !mtime_differs(st, file);
36 /* If always_checksum is set then we use the checksum instead
37 * of the file mtime to determine whether to sync. */
38 if (always_checksum > 0) {
39 diff --git a/options.c b/options.c
42 @@ -115,6 +115,7 @@ int safe_symlinks = 0;
43 int copy_unsafe_links = 0;
44 int munge_symlinks = 0;
47 int daemon_bwlimit = 0;
50 @@ -683,6 +684,7 @@ static struct poptOption long_options[] = {
51 {"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 },
52 {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
53 {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
54 + {"date-only", 0, POPT_ARG_NONE, &date_only, 0, 0, 0 },
55 {"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
56 {"no-one-file-system",0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
57 {"no-x", 0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
58 @@ -2803,6 +2805,9 @@ void server_options(char **args, int *argc_p)
59 else if (missing_args == 1 && !am_sender)
60 args[ac++] = "--ignore-missing-args";
63 + args[ac++] = "--date-only";
65 if (modify_window_set && am_sender) {
66 char *fmt = modify_window < 0 ? "-@%d" : "--modify-window=%d";
67 if (asprintf(&arg, fmt, modify_window) < 0)
68 diff --git a/rsync.1.md b/rsync.1.md
71 @@ -423,6 +423,7 @@ has its own detailed description later in this man page.
72 --contimeout=SECONDS set daemon connection timeout in seconds
73 --ignore-times, -I don't skip files that match size and time
74 --size-only skip files that match in size
75 +--date-only skip files that match in mod-time
76 --modify-window=NUM, -@ set the accuracy for mod-time comparisons
77 --temp-dir=DIR, -T create temporary files in directory DIR
78 --fuzzy, -y find similar file for basis if no dest file
79 @@ -683,6 +684,14 @@ your home directory (remove the '=' for that).
80 after using another mirroring system which may not preserve timestamps
85 + Normally rsync will skip any files that are already the same size and have
86 + the same modification time-stamp. With the `--date-only` option, files will
87 + be skipped if they have the same timestamp, regardless of size. This may be
88 + useful when the remote files have passed through a size-changing filter,
89 + e.g. for encryption.
91 0. `--modify-window=NUM`, `-@`
93 When comparing two timestamps, rsync treats the timestamps as being equal