Discussion:
How to sync an exact list of files, Including deletes!?
Axel Kittenberger
2010-11-20 21:56:13 UTC
Permalink
Hello,

I'm author of Lsyncd - the live syncing deamon -
http://code.google.com/p/lsyncd/ - a daemon that uses Linux` inotify
to watch for filesystem changes - aggregates them for a few seconds
and then periodically calls rsync to transfer the changes to
target(s). Version 1 was simply aware of directories only, and it
called rsync once with --delete -d for every directory in which
anything has happened. I'm now coding Version 2, this goes further and
keeps track for every file. Beside doing this to optimize on moves, I
want to optimize performance also with its interface to rsync.

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!

It says e.g. "rsync: link_stat "/tmp/ltest.M2e/src/z/t/fq" failed: No
such file or directory (2)" and refuses to delete the file on the
target.

What good solutions can you suggest?

I thought about instead of "--files-from=-" to use  "--recursive
--include-from=- --exclude=*". Beside I don't know how this evaluates
performance wise, it does not quite produce the effects, at least not
easily without further bloating the file-list. I suppose for every
directory on the include list, it needs to add rules for all parent
directories, so they get included in recursiveness.

Lsyncd does support a mode where ssh access is as well available on
the target. That way it can move moved files on the target, instead of
retransmitting them like a normal incremental rsync does. In that
case, it can as well simply log in there and call rm for removed
files. But I do want to support a rsync-only mode, for example if the
target runs the rsyncd daemon proving modules.

Could we get future versions of rsync accept "--delete --files-from=-"
rule to delete files and (recursively?) directories on the target that
are in the file-list but locally not existent?

Kind regards,
Axel
Steven Levine
2010-11-21 00:37:58 UTC
Permalink
In <AANLkTinDfc=***@mail.gmail.com>, on
11/20/10
at 10:56 PM, Axel Kittenberger <***@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!
What might work for the deletes is a dynamically built --exclude-from list
in combination with --delete excluded and possibly --prune-empty-dirs.
I've never tried this with --files-from, but it should work as long as
non-existant source file does not cause a problem with the filter logic.

You should not need --recursive. You just need the --exclude-from file to
contain full paths.


Steven
--
----------------------------------------------------------------------
"Steven Levine" <***@earthlink.net> eCS/Warp/DIY etc.
www.scoug.com www.ecomstation.com
----------------------------------------------------------------------
Steven Levine
2010-11-21 01:32:03 UTC
Permalink
In <AANLkTinDfc=***@mail.gmail.com>, on
11/20/10
at 10:56 PM, Axel Kittenberger <***@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" <***@earthlink.net> eCS/Warp/DIY etc.
www.scoug.com www.ecomstation.com
----------------------------------------------------------------------
Matt McCutchen
2010-11-21 01:53:50 UTC
Permalink
Post by Axel Kittenberger
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!
It says e.g. "rsync: link_stat "/tmp/ltest.M2e/src/z/t/fq" failed: No
such file or directory (2)" and refuses to delete the file on the
target.
What good solutions can you suggest?
You want the --delete-missing-args option of the current development
rsync.
--
Matt
Axel Kittenberger
2010-11-23 22:35:40 UTC
Permalink
Post by Matt McCutchen
You want the --delete-missing-args option of the current development
rsync.
Yes, I suppose I want that! :-) I hope this works with --force as well
if there is a dir in --files-from? But futher supposing it takes quite
a long time until I can suppose every user with medicore updateness
has a rsync installed that can do this. For now I made it in ssh-less
pure rsync-mode to call rsync once for with --files-from for all files
that created/changed, and then for every directory in which stuff has
been deleted/movedfrom.

I got another question tough running extensive tests, the daemon
happens to do this once in a while if creates/deletes/moves piling up
faster than inotify tracks, it calls rsync for a source->destination
pair, where the source dir no longer exists, normally would be no
problem:

$ /usr/bin/rsync -vP -d /tmp/ltest.WQS/src//n/c/d/ /tmp/ltest.WQS/trg//n/c/d/
building file list ...
rsync: change_dir "/tmp/ltest.WQS/src//n/c/d" failed: No such file or
directory (2)
0 files to consider
created directory /tmp/ltest.WQS/trg//n/c/d

I expect rsync to just fail in that case, but it creates the target
directory nevertheless :-( Is there some parameter I can add to rsync
so it wont create directories on the target, if there isnt a source
directory for it?

Kind regards, Axel
Post by Matt McCutchen
Post by Axel Kittenberger
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!
It says e.g. "rsync: link_stat "/tmp/ltest.M2e/src/z/t/fq" failed: No
such file or directory (2)" and refuses to delete the file on the
target.
What good solutions can you suggest?
You want the --delete-missing-args option of the current development
rsync.
--
Matt
Matt McCutchen
2010-11-23 23:29:45 UTC
Permalink
Post by Axel Kittenberger
Post by Matt McCutchen
You want the --delete-missing-args option of the current development
rsync.
Yes, I suppose I want that! :-) I hope this works with --force as well
if there is a dir in --files-from?
Yes.
Post by Axel Kittenberger
I got another question tough running extensive tests, the daemon
happens to do this once in a while if creates/deletes/moves piling up
faster than inotify tracks, it calls rsync for a source->destination
pair, where the source dir no longer exists, normally would be no
$ /usr/bin/rsync -vP -d /tmp/ltest.WQS/src//n/c/d/ /tmp/ltest.WQS/trg//n/c/d/
building file list ...
rsync: change_dir "/tmp/ltest.WQS/src//n/c/d" failed: No such file or
directory (2)
0 files to consider
created directory /tmp/ltest.WQS/trg//n/c/d
I expect rsync to just fail in that case, but it creates the target
directory nevertheless :-( Is there some parameter I can add to rsync
so it wont create directories on the target, if there isnt a source
directory for it?
Rsync always creates the destination directory; there is no way to stop
that. I would suggest using /tmp/ltest.WOS/trg/ as the destination
directory in combination with --relative.
--
Matt
(New Plaza F9) Lee, Sam
2010-11-24 00:42:16 UTC
Permalink
2010/11/23 23:36:52 [444] rsync: connection unexpectedly closed (255 bytes received so far) [generator]
2010/11/23 23:36:52 [444] rsync error: error in rsync protocol data stream (code 12) at io.c(641) [generator=3.0.4]



Hello��My Friends,what's mean that? Thanks!








-----ԭʼ�]��-----
���: rsync-***@lists.samba.org [mailto:rsync-***@lists.samba.org] ���� Matt McCutchen
�����: 2010��11��24�� 7:30
�ռ���: Axel Kittenberger
����: ***@lists.samba.org
��ּ: Re: How to sync an exact list of files, Including deletes!?
Post by Axel Kittenberger
Post by Matt McCutchen
You want the --delete-missing-args option of the current development
rsync.
Yes, I suppose I want that! :-) I hope this works with --force as well
if there is a dir in --files-from?
Yes.
Post by Axel Kittenberger
I got another question tough running extensive tests, the daemon
happens to do this once in a while if creates/deletes/moves piling up
faster than inotify tracks, it calls rsync for a source->destination
pair, where the source dir no longer exists, normally would be no
$ /usr/bin/rsync -vP -d /tmp/ltest.WQS/src//n/c/d/ /tmp/ltest.WQS/trg//n/c/d/
building file list ...
rsync: change_dir "/tmp/ltest.WQS/src//n/c/d" failed: No such file or
directory (2)
0 files to consider
created directory /tmp/ltest.WQS/trg//n/c/d
I expect rsync to just fail in that case, but it creates the target
directory nevertheless :-( Is there some parameter I can add to rsync
so it wont create directories on the target, if there isnt a source
directory for it?
Rsync always creates the destination directory; there is no way to stop
that. I would suggest using /tmp/ltest.WOS/trg/ as the destination
directory in combination with --relative.

--
Matt

--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~e
Robert Holtzman
2010-11-24 02:17:48 UTC
Permalink
Post by (New Plaza F9) Lee, Sam
2010/11/23 23:36:52 [444] rsync: connection unexpectedly closed (255 bytes received so far) [generator]
2010/11/23 23:36:52 [444] rsync error: error in rsync protocol data stream (code 12) at io.c(641) [generator=3.0.4]
Hello,My Friends,what's mean that? Thanks!
Why did you hijack the thread? Start a new one. This does *not* mean
simply changing the subject.
--
Bob Holtzman
Key ID: 8D549279
"If you think you're getting free lunch,
check the price of the beer"
(New Plaza F9) Lee, Sam
2010-11-24 03:55:43 UTC
Permalink
I'm,Sorry !

-----原始郵件-----
寄件者: rsync-***@lists.samba.org [mailto:rsync-***@lists.samba.org] 代理 Robert Holtzman
寄件日期: 2010年11月24日 10:18
收件者: ***@lists.samba.org
主旨: Re: �ظ�: How to sync an exact list of files, Including deletes!?
Post by (New Plaza F9) Lee, Sam
2010/11/23 23:36:52 [444] rsync: connection unexpectedly closed (255 bytes received so far) [generator]
2010/11/23 23:36:52 [444] rsync error: error in rsync protocol data stream (code 12) at io.c(641) [generator=3.0.4]
Hello,My Friends,what's mean that? Thanks!
Why did you hijack the thread? Start a new one. This does *not* mean
simply changing the subject.

--
Bob Holtzman
Key ID: 8D549279
"If you think you're getting free lunch,
check the price of the beer"
--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~es

Axel Kittenberger
2010-11-24 01:28:55 UTC
Permalink
Post by Matt McCutchen
Post by Axel Kittenberger
$ /usr/bin/rsync -vP  -d /tmp/ltest.WQS/src//n/c/d/ /tmp/ltest.WQS/trg//n/c/d/
building file list ...
rsync: change_dir "/tmp/ltest.WQS/src//n/c/d" failed: No such file or
directory (2)
0 files to consider
created directory /tmp/ltest.WQS/trg//n/c/d
I expect rsync to just fail in that case, but it creates the target
directory nevertheless :-( Is there some parameter I can add to rsync
so it wont create directories on the target, if there isnt a source
directory for it?
Rsync always creates the destination directory; there is no way to stop
that.  I would suggest using /tmp/ltest.WOS/trg/ as the destination
directory in combination with --relative.
Umm thank you, sorry for yet another qeustion, if I want to add a
filter with it as -delete-missing-args isnt out there yet, I've to
make incremental rules for this, right? For example to delete
./n/c/d/y

$ /usr/bin/rsync --relative --delete --force --include-from=-
--exclude=* /tmp/ltest.WQS/src/./n/c/d/ /tmp/ltest.WQS/trg/ < cat "#
n/
n/c/
n/c/d/
n/c/d/y/***"

In that case i could save --relative away,as its filtered anyway, or?
Axel Kittenberger
2010-11-23 22:37:48 UTC
Permalink
And another case if the parent directory of the target also doesnt exist:

/usr/bin/rsync -r /tmp/ltest.Pkr/src//l/w/c/r/a/ /tmp/ltest.Pkr/trg//l/w/c/r/a/
rsync: change_dir "/tmp/ltest.Pkr/src//l/w/c/r/a" failed: No such file
or directory (2)
rsync: mkdir "/tmp/ltest.Pkr/trg//l/w/c/r/a" failed: No such file or
directory (2)
rsync error: error in file IO (code 11) at main.c(594) [receiver=3.0.3]
rsync: connection unexpectedly closed (96 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at
io.c(635) [sender=3.0.3]

So far I guessed exit code 12 from the text to be a network error and
to keep trying it again - which I suppose isn't a good idea, since
this will never go trough until /tmp/ltest.Pkr/trg//l/w/c exists.
Post by Axel Kittenberger
Post by Matt McCutchen
You want the --delete-missing-args option of the current development
rsync.
Yes, I suppose I want that! :-) I hope this works with --force as well
if there is a dir in --files-from? But futher supposing it takes quite
a long time until I can suppose every user with medicore updateness
has a rsync installed that can do this. For now I made it in ssh-less
pure rsync-mode to call rsync once for with --files-from for all files
that created/changed, and then for every directory in which stuff has
been deleted/movedfrom.
I got another question tough running extensive tests, the daemon
happens to do this once in a while if creates/deletes/moves piling up
faster than inotify tracks, it calls rsync for a source->destination
pair, where the source dir no longer exists, normally would be no
$ /usr/bin/rsync -vP  -d /tmp/ltest.WQS/src//n/c/d/ /tmp/ltest.WQS/trg//n/c/d/
building file list ...
rsync: change_dir "/tmp/ltest.WQS/src//n/c/d" failed: No such file or
directory (2)
0 files to consider
created directory /tmp/ltest.WQS/trg//n/c/d
I expect rsync to just fail in that case, but it creates the target
directory nevertheless :-( Is there some parameter I can add to rsync
so it wont create directories on the target, if there isnt a source
directory for it?
Kind regards, Axel
Loading...