Guard against destination = existing directory

Wayne Davison wayned at samba.org
Tue Dec 3 23:19:16 MST 2013


On Tue, Dec 3, 2013 at 6:55 AM, Andre Majorel <aym-2cnysr at 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..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20131203/e979b8d0/attachment.html>


More information about the rsync mailing list