[CentOS] scp -rp behavior(SOLVED)

Sun Mar 1 16:07:08 UTC 2015
Valeri Galtsev <galtsev at kicp.uchicago.edu>

On Sun, March 1, 2015 9:44 am, Mark LaPierre wrote:
> On 02/26/15 19:45, Valeri Galtsev wrote:
>>
>> On Thu, February 26, 2015 6:34 pm, Mark LaPierre wrote:
>>> Hey all,
>>>
>>> I'm trying to copy configuration files from my old CentOS 6.6 32 bit
>>> machine to my new CentOS 6.6 64 bit machine.
>>>
>>> On my 32 bit machine:
>>>
>>> [mlapier at mushroom ~]$ ifconfig
>>> eth0      Link encap:Ethernet  HWaddr 00:19:DB:E5:4E:9F
>>>           inet addr:192.168.15.105
>>>
>>> When I issue this command on my new 64 bit machine, 192.168.15.101:
>>>
>>> scp -pr mlapier at 192.168.15.105: /home/mlapier/.thunderbird
>>> /home/mlapier/.thunderbird
>>
>> How about escaping dot (with backslash) for the remote machine, or just
>> giving the whole path for remote machine in quotes:
>>
>> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird"
>> /home/mlapier
>>
>> ?
>>
>> Also, if you want to specify destination directory (say with different
>> name) you will need to end directory with forward slash both on local
>> and
>> remote, like:
>>
>> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird/" \
>> /home/mlapier/.thunderbird/
>>
>> (this should be one line which didn't fit for me in one line hence
>> backslash...)
>>
>> Valeri
>>
>>>
>>> It copies all directories and files in 192.168.15.105: /home/mlapier/
>>> to
>>> 192.168.15.101: /home/mlapier.  I don't want all that, I just want the
>>> .thunderbird folder and all it's contents.
>>>
>>> The user and group account numbers match on the two machines for this
>>> user so that's not the issue.
>>>
>>> When I RTFM this is what I thought it said to do.  I'm I misreading the
>>> FM or is something weird going on here?

>
> Putting the source path in quotes, because of the dot, like this:
>
> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird" /home/mlapier
>
> worked.
>
> If the destination also contains a dot or other such character then put
> the destination in quotes too:
>
> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird"
> "/home/mlapier/.thunderbird"

Theoretically, you don't need to "escape with backslashes" or put in
quotes these things for paths on local machine. As everything that is not
escaped is expanded on local machine, this doesn't screw things up (the
best example: "~" is expanded into the value of path to user's home
directory. if it is escaped in the remote argument, the symbol "~" is
passed verbatim to the remote machine and is expanded on remote machine
(which you probably intend when using "~" in remote argument). Otherwise:
if it is not escaped, your shell on local machine expand "~" the way it
should be on local machine and passes the result of expansion to remote
machine, which may be different.

>
> but only include the destination directory if the destination directory
> does not yet exist otherwise you will get a copy of the source directory
> inside the destination directory like this:
>
> /home/mlapier/.thunderbird/.thunderbird


True, but only if you do not appends directory names with forward slashes.
However, if you append the directory in both arguments with forward slash,
what you say will not happen. E.g., say, /destination does exists, then:

rsync -avu /source/ /destination/

will result in /destination updated with all new stuff in /source (unless
something extra or newer is there in /destination, /desination becomes the
same as /source).

However, if you do not append directory name with forward slashes, the
behavior will be different, and will be exactly as you have described:

rsync -avu /source /destination

if /destination directory exists will put /source inside /destination.

So: appending directory name with slash changes rsync behavior as in
examples above. Is there anything I missed (or "messed" ;-) - anybody?

Valeri

++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++