[CentOS] scp -rp behavior(SOLVED)

Mon Mar 2 02:27:59 UTC 2015
Valeri Galtsev <galtsev at kicp.uchicago.edu>

On Sun, March 1, 2015 8:02 pm, Mark LaPierre wrote:
> On 03/01/15 10:44, 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?
>>>>
>>>> --
>>>>     _
>>>>    °v°
>>>>   /(_)\
>>>>    ^ ^  Mark LaPierre
>>>> Registered Linux user No #267004
>>>> https://linuxcounter.net/
>>>> ****
>>>> _______________________________________________
>>>> CentOS mailing list
>>>> CentOS at centos.org
>>>> http://lists.centos.org/mailman/listinfo/centos
>>>>
>>>
>>>
>>> ++++++++++++++++++++++++++++++++++++++++
>>> Valeri Galtsev
>>> Sr System Administrator
>>> Department of Astronomy and Astrophysics
>>> Kavli Institute for Cosmological Physics
>>> University of Chicago
>>> Phone: 773-702-4247
>>> ++++++++++++++++++++++++++++++++++++++++
>>> _______________________________________________
>>> CentOS mailing list
>>> CentOS at centos.org
>>> http://lists.centos.org/mailman/listinfo/centos
>>>
>>>
>>
>> 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"
>>
>> 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
>>
>
> Wow!  I didn't mean to start such a spirited discussion. ;-)
>
> Thank you all for your help and explanations.  Very enlightening.  Maybe
> I'll try out the rsync example when I copy all the user homes across.  I
> would have to know all the user passwords in order to use scp to copy
> over home directories that are not mine.  I already use rsync to do my
> nightly backups.
>

If you do rsync as root (on both remote and local machines), then you do
not need to know user's passwords. If you maintain machines under your
administration so that the same user/group has the same user ID/ group ID
on all machines, you can run "rsync -avu /from remote:/path/where", and it
will preserve UID/GID, timestamps and "types", e.g. a symlink will stay a
symlink,...

Do not consider rsync a good backup (even if you use -b "backup" flag
which preserves older copies by appending tilde). Real backup is you
friend. Depending you the park of machines you maintain you may use
something like backuppc (for small number of hosts) or bacula for large
number of machines. There are many to choose from, others may suggest good
ones they use.

Good luck!

Valeri

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