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: c528f8d5c8aa7b16b20cda72a9f4119699890c28
18 diff --git a/generator.c b/generator.c
21 @@ -65,6 +65,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 @@ -582,6 +583,9 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
30 /* Perform our quick-check heuristic for determining if a file is unchanged. */
31 int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
34 + return !mtime_differs(st, file);
36 if (st->st_size != F_LENGTH(file))
39 diff --git a/options.c b/options.c
42 @@ -111,6 +111,7 @@ int safe_symlinks = 0;
43 int copy_unsafe_links = 0;
44 int munge_symlinks = 0;
47 int daemon_bwlimit = 0;
50 @@ -837,6 +838,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 @@ -2723,6 +2725,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 @@ -415,6 +415,7 @@ detailed description below for a complete description.
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 @@ -640,6 +641,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`, `-@`
93 When comparing two timestamps, rsync treats the timestamps as being equal