LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 12-18-2010, 05:03 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Copy Files / Folders & Preserve Data


Can someone please help me with a command or way to copy a very large parent folder /data from 'server_old' to 'server_new' while preserving the data ownership (UID/GID) and file permissions? I tried running:

Code:
scp -rp /data/* root@server_new:/data/
Sadly the command above is not working for me and only copying everything over as root:root and not james:finance and other sub folders as jamesersonal. Is there a way to use tar, scp, rsync, or anything that will copy the permissions exactly?
 
Old 12-18-2010, 05:22 PM   #2
j1alu
Member
 
Registered: Apr 2009
Distribution: debian gnu/linux
Posts: 798

Rep: Reputation: Disabled
i use:
rsync -auv
 
Old 12-18-2010, 05:29 PM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Code:
rsync -auv /data/* root@server_new:/data/
Is that correct?
 
Old 12-18-2010, 05:31 PM   #4
j1alu
Member
 
Registered: Apr 2009
Distribution: debian gnu/linux
Posts: 798

Rep: Reputation: Disabled
That is what i would do, so i would say yes.
But rsync is always good for a surprise.
 
Old 12-18-2010, 07:48 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you use public key authentication for ssh on the new server, you could use tar as well

tar -C /data/ -cf - | ssh root@newserver 'tar -C /data/ -xf -'
 
Old 12-19-2010, 10:27 AM   #6
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
How come nobody's command has the '-p' switch and according to the 'man' page I should use it to preserve ownership.
 
Old 12-19-2010, 11:57 AM   #7
honeybadger
Member
 
Registered: Aug 2007
Location: India
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855

Rep: Reputation: Disabled
cp has the -p switch. I do not think rsync has that switch. I mean if you are syncing the files then ownership is automatically taken care of.
 
Old 12-19-2010, 12:00 PM   #8
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
What about 'tar' over 'ssh'? Does that require the -p switch of is that automatically handled?
 
Old 12-23-2010, 07:46 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The ownership and permissions should be preserved using tar if the UID exists on the remote backup host.
One thing nice about tar is you can use the tee command to save a tar backup as well, killing two birds with one stone. Handy if you have an external HD to backup to.
 
Old 12-31-2010, 12:13 PM   #10
networking.dept
Member
 
Registered: Dec 2010
Location: Ahmedabad
Distribution: Red Hat Enterprise Linux and Fedora
Posts: 44

Rep: Reputation: 8
Use Rsync to preserve permission, User and Group Ownership

Hello,

rysnc is always better to use.

You can use rsync as follows,

rsync -avzogpA

o and g for preserve user and group Ownership

A for Preserve ACLs if you have

Hope this helps
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy all files except from some certain folders. eikhorsholm Linux - Newbie 2 01-19-2010 04:53 PM
How to preserve a copy of system-level configuration files wiso2010 Linux - Newbie 3 07-08-2009 04:09 AM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
copy files and folders codepoet Linux - Newbie 2 06-12-2005 02:08 PM
how to copy files/folders??? Gallienus Linux - General 4 12-15-2003 12:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration