How to sync an exact list of files, Including deletes!?

Steven Levine steve53 at earthlink.net
Sat Nov 20 18:32:03 MST 2010


In <AANLkTinDfc=z8O37KS9TCRLEqPEumYd4753f_3MFbS9M at mail.gmail.com>, on
11/20/10
   at 10:56 PM, Axel Kittenberger <axkibe at gmail.com> said:

Hi,

>While running, Lsyncd knows exactly which files need transfer and rsync's
>--files-from (with =- to get the filelist from stdin-pipe) sounds like an
>ideal solution for this, also to reduce the number of times rsync gets
>spawned. Coded that, now in beta stage there is a nasty problem, rsync
>refuses to accept deletions that way!

My first idea did not work, which I thought might happen, but I came up
with a reasonably cheap alternative using -dirs and filters.

Try this command line

  rsync -n -i --dirs --delete-excluded -f._filters from/ to

where filters contains

+ file1
+ file2
R deleted
P *

The file list contains only file1 and file2 so the receiver has less work
to do than without the filters.  It should not be too difficult to expand
this method to work for source files spread across multiple directories.

One downside of this approach compared to --dirs without filters is that
if something goes wrong at just the right time, the source and destination
can get permamently out of sync.  However, for directories with a large
number of files, --dirs with filters should perform better.  Perhaps the
first update should use plain --dirs.

Steven

-- 
----------------------------------------------------------------------
"Steven Levine" <steve53 at earthlink.net>  eCS/Warp/DIY etc.
www.scoug.com www.ecomstation.com
----------------------------------------------------------------------



More information about the rsync mailing list