Re: rsync question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12Jul2020 16:06, bruce <badouglas@xxxxxxxxx> 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@xxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux