The patches for 3.3.0.
[rsync-patches.git] / date-only.diff
1 Jeremy Bornstein wrote:
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 To use this patch, run these commands for a successful build:
12
13     patch -p1 <patches/date-only.diff
14     ./configure                                 (optional if already run)
15     make
16
17 based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
18 diff --git a/generator.c b/generator.c
19 --- a/generator.c
20 +++ 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;
26  extern int size_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))
31                         return 0;
32  
33 +               if (date_only)
34 +                       return !mtime_differs(st, file);
35 +
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
40 --- a/options.c
41 +++ b/options.c
42 @@ -119,6 +119,7 @@ int safe_symlinks = 0;
43  int copy_unsafe_links = 0;
44  int munge_symlinks = 0;
45  int size_only = 0;
46 +int date_only = 0;
47  int daemon_bwlimit = 0;
48  int bwlimit = 0;
49  int fuzzy_basis = 0;
50 @@ -689,6 +690,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 @@ -2852,6 +2854,9 @@ void server_options(char **args, int *argc_p)
59         else if (missing_args == 1 && !am_sender)
60                 args[ac++] = "--ignore-missing-args";
61  
62 +       if (date_only)
63 +               args[ac++] = "--date-only";
64 +
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
69 --- a/rsync.1.md
70 +++ b/rsync.1.md
71 @@ -504,6 +504,7 @@ has its own detailed description later in this manpage.
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 @@ -776,6 +777,14 @@ expand it.
80      after using another mirroring system which may not preserve timestamps
81      exactly.
82  
83 +0.  `--date-only`
84 +
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.
90 +
91  0.  `--modify-window=NUM`, `-@`
92  
93      When comparing two timestamps, rsync treats the timestamps as being equal