Guard against destination = existing directory

2013-12-03 Thread Andre Majorel
Trying to use rsync to make sure that _dest_ is a regular file
with the same content as file _source_.

If _dest_ already exists and is a symlink, FIFO or device file,
rsync deletes it and creates a regular file in its place. Good.

If _dest_ already exists and is a directory, rsync creates
_dest_/$(basename _source_). Not what I want.

Is there an option similar to GNU install -T or GNU cp -T which
guarantees that if _dest_ exists and is a directory, rsync will
either remove it or fail, but NOT use it as a path ?

Thanks in advance.

-- 
André Majorel http://www.teaser.fr/~amajorel/
-- 
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/~esr/faqs/smart-questions.html


Re: Guard against destination = existing directory

2013-12-03 Thread Wayne Davison
On Tue, Dec 3, 2013 at 6:55 AM, Andre Majorel aym-2cn...@teaser.fr wrote:

 If _dest_ already exists and is a directory, rsync
 creates _dest_/$(basename _source_). Not what I want.


To do that with rsync you need to specify the destination directory,
leaving off the destination filename part. e.g. if you want to create
/dest/foobar from /src/foobar, you would copy:

rsync -aiv /src/foobar /dest/

See also --force if you want a /dest/foobar dir to be removed even if it is
not empty.

If you're wanting to change the name of a file for the transfer, the only
way to do that with this idiom is to create the new name on the source side
for the transfer, e.g.:

ln -s /src/foobar barbaz
rsync -aiv -L barbaz /dest/
rm barbaz

..wayne..
-- 
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/~esr/faqs/smart-questions.html