On 12Jul2020 16:06, bruce <badouglas(a)gmail.com> wrote:
assume
/home/test/user1/foo
/var/www/html
a user is in the "/" dir
how can this user copy/rsync "foo" dir to get /var/www/html/foo
i know you could cd to /home/test/user1 and
do
rsync -vv -aR foo/ /var/www/html/
which would get
/var/www/html/foo
Actually, no. That would put "foo/A" at "html/A", not at
"html/foo/A".
The above command makes the 2 directories '..../foo/' and '..../html/'
the same. If you remove the trailing '/' from the source:
rsync -vv -aR foo /var/www/html/
That causes rsync to create a "foo" _inside_ the "html/" directory.
The easy habit is this pair:
Make two directories the same:
rsync path/to/A/ other/path/to/B/
(no bare names after the final '/').
Make "A" inside "B":
rsync path/to/A other/path/to/B/
(a bare name in the source, trailing / in the target).
In general, rsync behaves like cp, ln, mv in that if the target is an
existing directoy it puts the source _inside_ it. So
rsync path/to/A other/path/to/B
makes an "other/path/to/B/A" _if_ "B" already exists. If it
doesn't, it
makes "B" like "A" because there's no preexisting directory.
I find it safer, usually, to make the target first ("mkdir
other/path/to/B") and use the earlier form:
rsync path/to/A/ other/path/to/B/
It never wants to make a new subdirectory, and fails if "B" does no
exist. Safer and more predictable all around.
Cheers,
Cameron Simpson <cs(a)cskk.id.au>