Commit | Line | Data |
---|---|---|
03019e41 | 1 | Jeremy Bornstein wrote: |
07b2cce7 MP |
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 | ||
03019e41 | 11 | To use this patch, run these commands for a successful build: |
07b2cce7 | 12 | |
03019e41 WD |
13 | patch -p1 <patches/date-only.diff |
14 | ./configure (optional if already run) | |
15 | make | |
c66bc26c | 16 | |
cc3e685d WD |
17 | diff --git a/generator.c b/generator.c |
18 | --- a/generator.c | |
19 | +++ b/generator.c | |
c0c7984e | 20 | @@ -62,6 +62,7 @@ extern int append_mode; |
58a9031f | 21 | extern int make_backups; |
7628f156 WD |
22 | extern int csum_length; |
23 | extern int ignore_times; | |
c66bc26c | 24 | +extern int date_only; |
58a9031f WD |
25 | extern int size_only; |
26 | extern OFF_T max_size; | |
e0e47893 | 27 | extern OFF_T min_size; |
65ecbe35 | 28 | @@ -711,6 +712,9 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre |
4c1f2ca5 | 29 | /* Perform our quick-check heuristic for determining if a file is unchanged. */ |
e0e47893 | 30 | int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st) |
c66bc26c WD |
31 | { |
32 | + if (date_only) | |
5b775703 | 33 | + return cmp_time(st->st_mtime, file->modtime) == 0; |
1aa236e1 WD |
34 | + |
35 | if (st->st_size != F_LENGTH(file)) | |
c66bc26c | 36 | return 0; |
4c1f2ca5 | 37 | |
cc3e685d WD |
38 | diff --git a/options.c b/options.c |
39 | --- a/options.c | |
40 | +++ b/options.c | |
c0c7984e | 41 | @@ -106,6 +106,7 @@ int keep_partial = 0; |
c66bc26c WD |
42 | int safe_symlinks = 0; |
43 | int copy_unsafe_links = 0; | |
44 | int size_only = 0; | |
45 | +int date_only = 0; | |
bad31232 | 46 | int daemon_bwlimit = 0; |
c66bc26c | 47 | int bwlimit = 0; |
a5e0f697 | 48 | int fuzzy_basis = 0; |
c0c7984e | 49 | @@ -388,6 +389,7 @@ void usage(enum logcode F) |
cc3e685d | 50 | rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n"); |
79f132a1 WD |
51 | rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n"); |
52 | rprintf(F," --size-only skip files that match in size\n"); | |
53 | + rprintf(F," --date-only skip files that match in mod-time\n"); | |
54 | rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n"); | |
d4e89c6a | 55 | rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n"); |
a5e0f697 | 56 | rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n"); |
c0c7984e | 57 | @@ -530,6 +532,7 @@ static struct poptOption long_options[] = { |
9a7eef96 | 58 | {"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 }, |
c66bc26c WD |
59 | {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 }, |
60 | {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 }, | |
61 | + {"date-only", 0, POPT_ARG_NONE, &date_only, 0, 0, 0 }, | |
e0e47893 | 62 | {"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 }, |
85096e5e WD |
63 | {"no-one-file-system",'x',POPT_ARG_VAL, &one_file_system, 0, 0, 0 }, |
64 | {"no-x", 'x', POPT_ARG_VAL, &one_file_system, 0, 0, 0 }, | |
c0c7984e | 65 | @@ -1953,6 +1956,9 @@ void server_options(char **args, int *argc_p) |
c8a8b4a7 | 66 | } |
5b775703 | 67 | } |
78114162 | 68 | |
c66bc26c WD |
69 | + if (date_only) |
70 | + args[ac++] = "--date-only"; | |
78114162 | 71 | + |
c66bc26c WD |
72 | if (modify_window_set) { |
73 | if (asprintf(&arg, "--modify-window=%d", modify_window) < 0) | |
78114162 | 74 | goto oom; |
cc3e685d WD |
75 | diff --git a/rsync.yo b/rsync.yo |
76 | --- a/rsync.yo | |
77 | +++ b/rsync.yo | |
78 | @@ -382,6 +382,7 @@ to the detailed description below for a complete description. verb( | |
79 | --contimeout=SECONDS set daemon connection timeout in seconds | |
79f132a1 WD |
80 | -I, --ignore-times don't skip files that match size and time |
81 | --size-only skip files that match in size | |
82 | + --date-only skip files that match in mod-time | |
83 | --modify-window=NUM compare mod-times with reduced accuracy | |
ed1e6fe4 | 84 | -T, --temp-dir=DIR create temporary files in directory DIR |
a5e0f697 | 85 | -y, --fuzzy find similar file for basis if no dest file |
cc3e685d | 86 | @@ -502,6 +503,12 @@ time to just looking for files that have changed in size. This is useful |
c8a8b4a7 WD |
87 | when starting to use rsync after using another mirroring system which may |
88 | not preserve timestamps exactly. | |
78114162 | 89 | |
c66bc26c WD |
90 | +dit(bf(--date-only)) Normally rsync will skip any files that are |
91 | +already the same size and have the same modification time-stamp. With the | |
92 | +--date-only option, files will be skipped if they have the same | |
93 | +timestamp, regardless of size. This may be useful when the remote | |
94 | +files have passed through a size-changing filter, e.g. for encryption. | |
78114162 | 95 | + |
c1adaf30 WD |
96 | dit(bf(--modify-window)) When comparing two timestamps, rsync treats the |
97 | timestamps as being equal if they differ by no more than the modify-window | |
98 | value. This is normally 0 (for an exact match), but you may find it useful |