Operating System - HP-UX
1821984 Members
3354 Online
109638 Solutions
New Discussion юеВ

how to use cpio to transfer files from one server to another

 
SOLVED
Go to solution
Shawn Miller_2
Frequent Advisor

how to use cpio to transfer files from one server to another

What is the syntax and commands that I need to cpio a whole directory with all its files to another server. I will be coping large files and links. The links need to be copied as links.
9 REPLIES 9
Pete Randall
Outstanding Contributor

Re: how to use cpio to transfer files from one server to another

cd /nfs/servername/dirname
find . -print |cpio -pdumxl /otherdir

That's my method, anyway.


Pete

Pete
Shawn Miller_2
Frequent Advisor

Re: how to use cpio to transfer files from one server to another

The /otherdir is on another server. How do I go about doing that. I do not want to create an archive file then ftp that archive file over. I would like this all done in one line. Any suggestions.
Pete Randall
Outstanding Contributor

Re: how to use cpio to transfer files from one server to another

Shawn,

That's where NFS comes in. I'm starting from the target server when I do my "cd /nfs/otherserver/dirname". If you're not using NFS, then the technique would obviously need to be different.


Pete

Pete
Richard Pereira_1
Regular Advisor

Re: how to use cpio to transfer files from one server to another

Sorry man, CPIO doesnt natively understand network tranfers. You'll have to archive and then it ftp over.

Try this syntax
# find . -print | cpio -pdmuv > /tmp/myarchive.cpio

Test it out, but this syntax should keep the ownerships and permissions intact.

Good luck
curt larson_1
Honored Contributor
Solution

Re: how to use cpio to transfer files from one server to another

a link to where this has been answered before

[Broken link removed on <4/18/2017> by Mod]

On machine A
=============
# cd /data2
# (find . -xdev|cpio -coax) | remsh machineB "cd /data2;cpio -icdmula"

and you can use tar in a similar way

Shawn Miller_2
Frequent Advisor

Re: how to use cpio to transfer files from one server to another

I have done this in the distant past and forgot how I did it. But with in the same line using pipes I created the archive then used something like rcp to copy and then unarchived it into the destination directory. That way I do not need to find space on the current system for the archive file that then needs to be ftp or rcp over. Does anyone have an idea on how that is done.
Pete Randall
Outstanding Contributor

Re: how to use cpio to transfer files from one server to another

Shawn,

It looks like Curt's solution should do the job for you.


Pete

Pete
Robert-Jan Goossens
Honored Contributor

Re: how to use cpio to transfer files from one server to another

Hi,

# cd /source
# find . | cpio -ov | remsh server_name " cd /copy ; cpio -idvum "

Regards,
Robert-Jan
Shawn Miller_2
Frequent Advisor

Re: how to use cpio to transfer files from one server to another

Thanks everyone. Here is what I ended up using.

(find . -xdev|cpio -coa) | remsh serverB "cd /p01; cpio -icdmul"

The -a and -m were exclusive and it was important to have it on for the first cpio and to have the -m for the second.