-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdate-only.diff
93 lines (85 loc) · 3.64 KB
/
date-only.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Jeremy Bornstein wrote:
I recently had the need to transfer files only with different mod
dates (and to *not* transfer them based on file size differences).
This is because I'm backing up files remotely on an untrusted machine,
so I'm encrypting them with gpg before transfer. I discovered that
rsync didn't already have a --date-only flag, so I added one and am
enclosing the diffs in case you (as I hope) decide to include this
option in future releases.
To use this patch, run these commands for a successful build:
patch -p1 <patches/date-only.diff
./configure (optional if already run)
make
based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
diff --git a/generator.c b/generator.c
--- a/generator.c
+++ b/generator.c
@@ -67,6 +67,7 @@ extern int append_mode;
extern int make_backups;
extern int csum_length;
extern int ignore_times;
+extern int date_only;
extern int size_only;
extern OFF_T max_size;
extern OFF_T min_size;
@@ -621,6 +622,9 @@ int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file
if (st->st_size != F_LENGTH(file))
return 0;
+ if (date_only)
+ return !mtime_differs(st, file);
+
/* If always_checksum is set then we use the checksum instead
* of the file mtime to determine whether to sync. */
if (always_checksum > 0) {
diff --git a/options.c b/options.c
--- 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 date_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 },
+ {"date-only", 0, POPT_ARG_NONE, &date_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 },
@@ -2852,6 +2854,9 @@ void server_options(char **args, int *argc_p)
else if (missing_args == 1 && !am_sender)
args[ac++] = "--ignore-missing-args";
+ if (date_only)
+ args[ac++] = "--date-only";
+
if (modify_window_set && am_sender) {
char *fmt = modify_window < 0 ? "-@%d" : "--modify-window=%d";
if (asprintf(&arg, fmt, modify_window) < 0)
diff --git a/rsync.1.md b/rsync.1.md
--- 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
+--date-only skip files that match in mod-time
--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,14 @@ expand it.
after using another mirroring system which may not preserve timestamps
exactly.
+0. `--date-only`
+
+ Normally rsync will skip any files that are already the same size and have
+ the same modification time-stamp. With the `--date-only` option, files will
+ be skipped if they have the same timestamp, regardless of size. This may be
+ useful when the remote files have passed through a size-changing filter,
+ e.g. for encryption.
+
0. `--modify-window=NUM`, `-@`
When comparing two timestamps, rsync treats the timestamps as being equal