git @ Cat's Eye Technologies ellsync / fb321c7
Pass --checksum to rsync and remove the --thorough option. Chris Pressey 2 years ago
2 changed file(s) with 7 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
6060
6161 and this will in effect run
6262
63 rsync --archive --verbose --delete --dry-run /home/user/art/ /media/user/External1/art/
63 rsync --archive --verbose --delete --checksum --dry-run /home/user/art/ /media/user/External1/art/
6464
6565 Note that by default it only runs a `--dry-run`. It's a good practice to
6666 do a dry run first, to see what will be changed. As a bonus, the files
8484
8585 is still interpreted as
8686
87 rsync --archive --verbose --delete /home/user/art/ /media/user/External1/art/
87 rsync --archive --verbose --delete --checksum --dry-run /home/user/art/ /media/user/External1/art/
8888
8989 (but note that the directories in the router do need to have the
9090 trailing slashes.)
107107 uncommon occurrence on inexpensive removable media), `rsync` will not attempt
108108 to repair the corruption, as the timestamp of the corrupted file did not change.
109109
110 To compensate for this, `ellsync` provides the `--thorough` flag. This
111 changes the timestamps of all the files in the destination to January 1st, 1970.
112 This will cause `rsync` to actually check the contents of each file and actually
113 sync any needed changes. The timestamp will be set to the timestamp of the
114 source file as part of the this sync.
110 To compensate for this, `ellsync` invokes `rsync` with the `--checksum` flag, to
111 force it to do a thorough check of the files. See `man rsync` for more details.
115112
116113 ### `list` command
117114
198195
199196 Added `--stream-name-only` option to `list` command.
200197
201 Added `--thorough` to `sync` and `syncdirs` commands.
198 `rsync` is now invoked with `--checksum` flag to cause it to thoroughly check if
199 files differ, even if their datestamps have not changed.
202200
203201 ### 0.2
204202
1818 if not os.path.isdir(d):
1919 raise ValueError("Directory '{}' is not present".format(d))
2020 rsync_options = '--dry-run ' if dry_run else ''
21 cmd = 'rsync {}--archive --verbose --delete "{}" "{}"'.format(rsync_options, from_dir, to_dir)
21 cmd = 'rsync {}--archive --verbose --delete --checksum "{}" "{}"'.format(rsync_options, from_dir, to_dir)
2222 run_command(cmd)
2323 if not dry_run:
2424 run_command('sync')
6767 from_dir = clean_dir(from_dir)
6868 to_dir = clean_dir(to_dir)
6969
70 if options.thorough and options.apply:
71 cmd = 'find "{}" -exec touch --date "1970-01-01" {} \;'.format(to_dir, '{}')
72 run_command(cmd)
73
7470 perform_sync(from_dir, to_dir, dry_run=(not options.apply))
7571
7672
8985 if selected_stream_name is None:
9086 raise ValueError("Stream {} => {} was not found in router".format(from_dir, to_dir))
9187
92 if options.thorough and options.apply:
93 cmd = 'find "{}" -exec touch --date "1970-01-01" {} \;'.format(to_dir, '{}')
94 run_command(cmd)
95
9688 perform_sync(from_dir, to_dir, dry_run=(not options.apply))
9789
9890
177169 parser_sync.add_argument('--apply', default=False, action='store_true',
178170 help='Actually run the rsync command'
179171 )
180 parser_sync.add_argument('--thorough', default=False, action='store_true',
181 help='Invalidate the timestamp on all destination files, to ensure content is synced'
182 )
183172 parser_sync.set_defaults(func=sync)
184173
185174 # - - - - syncdirs - - - -
194183 )
195184 parser_syncdirs.add_argument('--apply', default=False, action='store_true',
196185 help='Actually run the rsync command'
197 )
198 parser_syncdirs.add_argument('--thorough', default=False, action='store_true',
199 help='Invalidate the timestamp on all destination files, to ensure content is synced'
200186 )
201187 parser_syncdirs.set_defaults(func=syncdirs)
202188