Flag file management techniques using rsync
terabite at bigpond.com
Sun Nov 7 11:54:56 GMT 2004
I am just getting into rsync and have been very impressed with performance
and reliability. There is one thing I haven't worked out how to do yet and
I haven't found much with several Google sessions or by way of consulting
I am looking for a way to check for (or duplicate) single flag files to and
from a remote host (without any dummy spit errors when it is not present)
and ideally avoiding the need for a specialised sub directory for each flag
file. For example to see if the remote host is otherwise occupied (i.e.. in
the middle of building the import data files) I was expecting this might
work for a "pull" action...
rsync -vptgo rmtusr at rmthost.net:/somepath/file1.flg file1.flg
while [ -f file1.flg ]
rsync -vptgo --delete rmtusr at rmthost.net:/somepath/file1.flg file1.flg
# Now safe to transfer the data
rsync -rvptgo rmtusr at rmthost.net:/somepath/export import/
... then I want to drop a flag file on the remote host before a "push" rsync
starts and then remove it on completion. eg.
rsync -vptgo file2.flg rmtusr at rmthost.net:/somepath/file2.flg
rsync -rvptgo export/ rmtusr at rmthost.net:/somepath/import/
rm -f file2.flg
rsync -vptgo --delete file2.flg rmtusr at rmthost.net:/somepath/file2.flg
In my initial attempts the --delete options didn't seem to work to well on
single files. I had thought of using discrete subdirectories for each flag
file so I can use the -r option with the --delete but I was hoping to avoid
this so a general solution would be much easier to deploy (and scale).
Is there a better way to achieve these goals using rsync or perhaps are
there better options using ssh alone? Regards, Frank.
More information about the rsync