Copy folder and files from unix server to linux server

We would be migrating unix solaries to Linux redhat.
Basically source is unix and target is linux.

i would like to copy entire file system unix/source/* to target linux/souce/*
but target linux has only folder setup so what ever files copied need to be placed in the linux server with same folder.
I am not so familar with unix world.
Please help me to copy the source filesystem to taget filesystem with out changing owner and permission.
what would be the best way to accompalsi this item.
We want to write csh Shell automated script to copy one server filesystem ( unix) to another server ( linux 2.6) and make sure the file permission not be changed.

I dont know which is the one is so good , SCP , tar

Please do the needful.
Thanks.
ram

If you have rsync on solaris this is a pretty good choice. You will need to get ssh login between the two machines working first.

Then try something like this from the solaris box, assuming you linux box is named "linux_box":

# rsync -axvz --progress --bwlimit=2000 /unix/source/ linux_box:/linux/source

--bwlimit=2000 helps reduce the network load (set as you see fit, or remove for no bandwidth limit). You can stop the copy at any point and it will check and files already there and only copy what is needed.

We have Unix SunOS 5.10 as a source , which not supporting rsync .

% man rsync
No manual entry for rsync.

Please help me with feasible solution.

Thanks in advance.

One option is to install rsync on your source box, it's available via Sunfreeware - Free and Open Source Software (FOSS) for Sun Microsystem's Solaris (make sure you also get the dependancies if you dont have them)

If that is too much trouble and you have heaps of free diskspace on the source box (and dest box) you can tar the filesystem to a file, move it to source and extract there:

source % cd /unix/source
source % tar cf /scratch/source.tar .
source % rcp /scratch/source.tar dest:/scratch/source.tar
...
dest % cd /linux/source
dest % tar xf /scratch/source.tar

Otherwise, you could transfer the tar over ssh and extract all in one. Make sure you can connect first with something like source % ssh linux_box id

source % cd /unix/source
source % tar cf - . | ssh linux_box 'cd /linux/source ; tar xf -'

I am really thank ful for your help.
i am planning to use the below code , as you suggested.
I sincerely appreciate it.

i have mention code 1 & 2 , which is the best way and please correct the syntax too. Thanks a lot for all your help.
------------------------------------------------
Source unix server ip : 192.168.10.1
Source directory : usr/local/adm

target linux server ip : 192.168.10.2
target directory : usr/local/adm

Please correct me i am wrong with syntax

----------------------------------------
code 1:

Source server shell:
--------------------

-- change directory
cd /usr/local/adm
-- copy source filesystem to target file system tar & extract to target server
tar cf - ./cd /usr/local/adm/source.tar | ssh 192.168.10.2 'cd /usr/local/adm/source.tar ; tar xf -'

please correct me if i am wrong with the syntax.

Code 2 :

Source server shell:
--------------------

-- change directory
cd /usr/local/adm

-- zipping the file in the current directory itself
tar cf /usr/local/adm/source.tar

-- copy from source to targer server , how to modify the based on server
scp /usr/local/adm/source.tar dest:/scratch/source.tar

target server shell:
--------------------

cd /linux/source
tar xf /usr/local/adm/source.tar

If you have a reliable and fast network code 1 is quite an acceptable method to use and doesn't require additional space.

If you need to go with code 2 method try and run everything from 1 script on the source machine so you don't have to wait around for archive and network copy to finish so you can start extract. Try and avoid putting .tar file in the same directory you are archiving as tar will pick up it's on file and try to read this in. It's best from a performance viewpoint to have .tar file on a different physical disk.

Pick a small subdirectory (with a small size and a small directory tree) to test scripts with, as you don't want the script running for hours and then find the

code 1:

Source server shell:
--------------------

-- change directory
cd /usr/local/adm
-- copy source filesystem to target file system tar & extract to target server
tar cf - . | ssh 192.168.10.2 'cd /usr/local/adm/source.tar ; tar xf -'

Code 2 :

Source server shell:
--------------------

-- change directory
cd /usr/local/adm

-- Avoid writing to same directory you are archiving as tar will pickup the tar file and try to tar this causing issues. I'd suggest putting the zip in another filesystem preferablly on physically seperate disks for more performance.

tar cf /scratch/source.tar .

-- copy from source to targer server , how to modify the based on server
scp /scratch/source.tar 192.168.10.2:/scratch/source.tar

-- fire restore off on target machine (best done in this script as you can run it unattended, ie you wount have to be around at midnight when scp finishes)

ssh 192.168.10.2 'cd /usr/local/adm/ ; tar xf /scratch/source.tar'

i am able to copy a file from one server to another server.
in the below command i want to add switch user command , marked in red but i am getting error with su option.
Please help me to correct the syntax.
Thanks a lot for all your help.

tar cf - . | ssh [EMAIL="u123@10.20.30.120"]u123@10.20.30.120[/EMAIL] 'su - trw ; 'cd /export/home/u196907 ; tar xf -'

Best idea is to get keyless ssh working for user trw and then ssh directly to user required:

tar cf - . | ssh trw@10.20.30.120 'cd /export/home/u196907 ;  tar xf -'

[/SIZE][/FONT]

thank you so much for the info.

source system :

file 1 uploaded by xyx

using tar cf - . | ssh [EMAIL="u123@10.20.30.120"]u123@10.20.30.120[/EMAIL] 'su - trw ; 'cd /export/home/u07 ; tar xf -'

after file copied to target system

file1 uploaded by u123

--- basically owner of the file is changing to u123 ,we need same owner like source system xyz

how to keep the same file owner as source system. there is any we can control the file owner

Please advise.