Batch mode scenario ("use case")
Suresh Govindachar
sgovindachar at yahoo.com
Mon Sep 10 01:31:23 GMT 2007
Chris wrote:
> Suresh wrote:
>>
>> Responding to the question of how to use the batch file
>> /e/cmds/foo created via the command:
>>
>>> rsync -a --only-write-batch=/e/cmds/foo /c/home/wer/work/ /e/gold
>>
>> to selectively restore a subdirectory of work/ such as
>>
>> some/path/projects/c_a
>>
>> into a new location such as
>>
>> /f/new_home/wer/work
>>
>> which has a copy of some/path/projects/c_a gotten from /e/gold but
>> is otherwise empty, Matt wrote:
>>
>>> Rsync currently doesn't provide a good way to do this. It would
>>> be great if sender filters could be used to control which
>>> file-list entries from the batch file are processed. For now, a
>>> hackish way to quickly recover a subdirectory is to --read-batch
>>> to a destination that has been set up specially so that the user
>>> cannot write to anything in the destination except the
>>> subdirectory to be recovered.
>>
>> Is there a specification for the format of the batch file?
>> Might it be possible to write a script to read /e/cmds/foo and
>> create a new batch file that would correspond to having been
>> created while
>> rsync'ing --only-write-batch of work/<path>/c_a with gold/<path>/c_a?
>
> The batch file format is simply a dump of rsync's network
> protocol. That way, replaying the batch file is quite similar to
> performing the original sync, except for the bytes come from the
> file instead of from the socket.
>
> At least, that's the way it worked last time I looked, which was
> several years ago.
How about the following scheme? To help with the following scheme,
it would be OK to require that there be no symbolic links from
within c_a to outside c_a; and that "--log-file=log" have been used
in the original rsync command (the one that generated /e/cmds/foo).
The log file might help with fine-tuning the following scheme:
open /e/cmds/foo
<do till end-of-file>:
<begin-continue>
discard lines till there is a match to some/path/projects/c_a
keep lines till there is a match to a directory outside c_a
Note that the lines being kept could be
data/commands corresponding to files inside c_a
<end-continue>
<end-do>
write kept lines to new batch file
Will the lines kept correspond to the batch file for
rsync'ing --only-write-batch of work/<path>/c_a with gold/<path>/c_a?
How can the log file be used to fine tune the above scheme?
Thanks,
--Suresh
More information about the rsync
mailing list