1835102 Members
2329 Online
110073 Solutions
New Discussion

cpio help

 
SOLVED
Go to solution
Duffs
Regular Advisor

cpio help

Hi,

I want to duplicate the home dir of a RH linux server onto another linux machine. I have scp'ed the entire dir over however this does not preserve permission or ownership rights.

I believe cpio can effectively do this however I have never used cpio before. The man pages mention how to cpio a dir to a new dir but can I alternatively use cpio to create a file that I can scp to the /home dir of my other server and import so that the entire sub dir structures will be identical and username/permissions will be in tact?



4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: cpio help

Yes that method will work and all ownerships and file modes will be preserved.

On the source box,
cd to desired starting directory
find . -print | cpio -ocv > /tmp/xxx.cpio
or
cd /
find /home -print | cpio -ocv > /tmp/xxx.cpio

Now ftp, rcp, or scp /tmp/xxx.cpio to the target machine.

On the target machine:
cd to desired starting directory:
cpio -icvdum < /tmp/xxx.cpio


If it ain't broke, I can fix that.
Sanjay_6
Honored Contributor

Re: cpio help

Hi,

You can create a tar archive and then scp it to the other system and untar the archive over there.

Is that possible.

Hope this helps.

Regds
H.Merijn Brand (procura
Honored Contributor

Re: cpio help

In that case, please just stick to scp and use the -p option

â p Preserves modification times, access times, and modes from the original file.

For cpio it would be something like

hosta# find . | cpio -ocv >/tmp/xx.cpio
hostb# cpio -iuvdma
Enjoy, Have FUN! H.Mer
Enjoy, Have FUN! H.Merijn
Duffs
Regular Advisor

Re: cpio help

Thats perfect, thanks lads.