Bug 14341 - --compare-source to filter file list at sender
Summary: --compare-source to filter file list at sender
Status: NEW
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.3
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2020-04-08 14:42 UTC by Haravikk
Modified: 2020-04-08 14:43 UTC (History)
0 users

See Also:


Description Haravikk 2020-04-08 14:42:54 UTC
This proposal is for a new option similar to --compare-dest, for specifying a local directory structure on the sending side that can be used to more quickly narrow down the list of files that have changed, especially useful when sending from a file system containing multiple backups/snapshots that can be compared locally, and useful when sending over a slower remote connection (by minimising the file list).

The option would take the form:

    --compare-source {path}

Where {path} points to a parallel file structure that rsync should compare against locally before sending files.

For example, I use rsync to synchronise my Mac's local Time Machine backups over to a remote NAS. If my latest backup is 2020-04-08-152937 and I know that I have previously synchronised the earlier backup 2020-04-08-142243 then I might do the following:

    rsync -a --compare-source "/Volumes/Backup/Backups.backupdb/My Mac/2020-04-08-142243" "/Volumes/Backup/Backups.backupdb/My Mac/2020-04-08-152937" "user@MyNas.local:/volume1/Backups/My Mac/Latest"

With the above command rsync would scan through files and directories in the 2020-04-08-152937, and compare them against the same path in 2020-04-08-142243 (if it exists), any file or directory found not to have changed between the two by time and size, or by inode number (if on the same device) will be skipped from the transfer without deleting, equivalent to excluding and protecting the file/directory (to prevent deletion with --delete-excluded).

Currently to achieve this requires the use of a complex (and slow) find command to compare inodes, passing in its results as a filter list of exclude and protect statements; this works, but it isn't terribly efficient and effectively blocks rsync from transferring anything until the find command has finished (i.e- the filter list is complete). If rsync were to perform the comparison against a local file structure itself then it would a lot faster.

Of course this option should only be used when you are sure that the previous directory you are comparing against has already been synchronised previously, but when using rsync to create additional backups this can be done safely.