Operating System - HP-UX
1830272 Members
2597 Online
110000 Solutions
New Discussion

Copying files between systems but not link files

 
SOLVED
Go to solution
Simon R Wootton
Regular Advisor

Copying files between systems but not link files

I have two systems and want to copy the contents of :

/data1
/data2
/data3
/data4

from one machine to another. My problem is that the original machine has several link files linking directories eg.

/data2/abc/tst -> /abc/tst

When copying the data, it appears to physically copy the data from the link and not the link file.

I'm using rcp to copy between machines but I don't want to copy link files.

Can anyone help ? Points allocated for valuable help !
9 REPLIES 9
Robert-Jan Goossens
Honored Contributor
Solution

Re: Copying files between systems but not link files

Hi,

# find /dir | cpio -ov | remsh server; cd /dir | cpio -idvum

Hope it helps,

Robert-Jan.
S.K. Chan
Honored Contributor

Re: Copying files between systems but not link files

I'm using cpio to copy data from one machine to another, preserving the symbolic link and the file attributes. Setup remsh capability (this can be temporary if security risk is a concern) between machine A and B. Say you wanted to copy /data2 (in machine A) to /data2 (in machine B) , you can run this ..
On machine A
=============
# cd /data2
# (find . -xdev|cpio -coax) | remsh machineB "cd /data2;cpio -icdmula"
I've been using this method for quite some time now.
S.K. Chan
Honored Contributor

Re: Copying files between systems but not link files

You can drop the "x" in the first cpio since you're not dealing with device file. Sorry ..
S.K. Chan
Honored Contributor

Re: Copying files between systems but not link files

Since I'm in it, might as well post another option of doing this. If you're running it from machine B, then ..
# cd /data2
# remsh machineA "cd /data2;find . -xdev|cpio -coa"|cpio -icdmula
Robert-Jan Goossens
Honored Contributor

Re: Copying files between systems but not link files

Mr Chan is correct

I missed the quotes

# find /dir | cpio -ov | remsh server " cd /dir ; cpio -idvum"

sorry,

Robert-Jan.
Geoff Wild
Honored Contributor

Re: Copying files between systems but not link files

Here's what I do:

nfs mount the remote machine.

cd on the local machine to the top level directory, then:

find . -depth -print | cpio -pdxm /newlocaldir/


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Bill Douglass
Esteemed Contributor

Re: Copying files between systems but not link files

We use OpenSSH for communicating between hosts. Here's an example using these:

tar cf - /data1 /data2 /data3 /data4 | ssh host2 tar xf -

tar will write its archive to standard output (- option), which is piped into the ssh command.

ssh in turns sends the output to host2, where it is fed as standard input to the tar command there.

Simon R Wootton
Regular Advisor

Re: Copying files between systems but not link files

Thanks to all for your help. I will look into the options today and have a go this weekend.

Regards
Simon
Gary Yu
Super Advisor

Re: Copying files between systems but not link files

Hi ,

you can tar the directory first, then rcp to the other server, then untar it.

tar will not include the real datafile of a link but only the link itself.

thanks,
Gary