Creating a third difference-only folder using rsync to compare 2 folders

Wayne Davison wayned at samba.org
Sat Jun 24 17:39:02 GMT 2006


On Sat, Jun 24, 2006 at 01:51:20PM +0100, Eoin O'Sullivan wrote:
> I am using rsync to update 1 folder based on changes in the other folder
> however I also need to compile a 2nd copy of ONLY the files that have
> changed and put these in a 3rd folder so I can FTP them to a live
> website (which doesn't support rsync). 

That's the purpose of the --compare-dest option.   Do the copy from a
source dir to an empty dir using the last-copied destination dir as the
arg for --compare-dest.  Only changed files will be placed into the
destination.  After ftping them to the live website, you can move them
into the last-copied destination dir and repeat.  If you need to know
about deleted files, you'll need to do one additional copy after this
that only deletes files in the updated destination by using both the
--existing and the --ignore-existing options along with --delete (this
avoids doing any file transfers).  If you make a note of what files get
deleted (by using a script to scan the output), you can duplicate those
deletions on the ftp site.

> Folder A (contains website with some changes)
> Folder B (contains older version of website)
> Folder C (should contain only the files/folders that are different
> between A & B)

The following presumes A, B, and C are all in the same dir.  Use full
paths as needed if they are not:

    rsync -av --compare-dest=../B A/ C
    # ftp each file from C to remote site and move it into B.
    rsync -av --existing --ignore-existing --delete A/ B | tee dels
    # perform deletions mention in "del" on remote site.

..wayne..


More information about the rsync mailing list