remote copying

Hi All,

I am using Digital Unix v5.1b.

I would like to copy a folder which contains many sub directories from a remote machine.

I think I can use the rcp command.

But I need to meet the following 2 conditions:

1.) the file permission, owner of all directories/files will not be modified.

2.) retain all the symbolic link under this folder.

How can i achieve this? Pls advise. Thanks.

Further, I would like to rename the folder at the desintation workstation first before remote copying a folder.
Can I use the mv command  to rename a folder which contains many directories/files?
ee_lcpaaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brettmjohnsonCommented:
Log into the remote machine (via ssh, slogin, rlogin, or telnet)
Use tar on the remote machine to create an archive  use the -r and -s switches to maintain permissions.
By default, tar already preserves symbolic links (unless you use the -h switch to dereference symlinks).
  tar -crsf MyArchive.tar mySourceFolder

Copy the tar file (MyArchive.tar) from the the remote machine to the local scp, rcp, or ftp.

Untar the archive on the local machine, again using the -r and -s switches to preserve permissions and file order:
  tar -xrsf MyArchive.tar

gheistCommented:
Same but over network:

(cd courcedir && tar cpf - * ) | ssh user@desthost '(cd destdir && tar xfp - )

you can use rsh instead of ssh if ssh is slow and you do not need security

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ee_lcpaaAuthor Commented:
Dear brettmjohnson,

I can't run the command "tar -crsf /tmp/test.tar FolderOne"

ws01> tar -crsf /tmp/test.tar FolderOne
tar: you must specify exactly one of the c, t, r, u or x options
Usage: tar  c[bBfFhlnoRSvw0-9] block device filename density [-e exception]                  [-C directory filename ..] [filename..]
       tar -c[BFhlnovw0-9] [-b block] [-f device] [-S density] [-R filename]                 [-e exception] [-C directory filename ..]
 [filename..]

       tar  r[bBfFhlnoRSvw0-9] block device filename density [-e exception]                  [-C directory filename ..] [filename...]
       tar -r[BFhlnovw0-9] [-b block] [-f device] [-S density] [-R filename]                 [-e exception] [-C directory filename ..]
 [filename...]

       tar  t[vfizS0-9] device density
       tar -t[vzi0-9] [-f device] [-S density]

       tar  u[bBfFhlnoRSvw] block device filename density [-e exception]                     [-C directory filename ..] [filename...]
       tar -u[Bfhlnovw] [-b block] [-f device] [-S density] [-R filename]                    [-e exception] [-C directory filename ..]
 [filename...]

       tar  x[BflLmopPRsSvwz0-9] device Prefix filename density [filename...]
       tar -x[BlLmopsvwz0-9] [-f device] [-S density] [-P Prefix] [-R filename]               [filename...]

I have checked the man page.

r   Writes the named files at the end of the specified archive.  If the
     archive is on tape, tar expects that the tape is currently positioned
      to the beginning of the archive.

s   [Compaq]  Tells tar to strip off any leading slashes from pathnames during extraction.  This is useful when restoring a tape that was created on a system with a different file system structure.  

How can I achieve the 2 requirements?

1.) keep the curent file permission, ownership

2.) retain all the symbolic link.

Further, I've tried to create a tar file by tar cvhf /tmp/test.tar FolderOne. I found the symbolic link can't be retained.

Please advise.
Thanks!
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

brettmjohnsonCommented:
> 1.) keep the curent file permission, ownership

Use the -p switch:
     -p
     --same-permissions
     --preserve-permissions  Extract all protection information.


> 2.) retain all the symbolic link.

tar does this by default.


I have no idea what orifice I pulled '-r' out of...

gheistCommented:
It came from GNU tar
     -r, --append  Append the named new files to existing archive.  Note that
                   this will only work on media on which an end-of-file mark
                   can be overwritten.

brettmjohnsonCommented:
> I have no idea what orifice I pulled '-r' out of...
> > It came from GNU tar
> >      -r, --append  Append the named new files to existing archive.  Note that...

Yes I know, but I was commenting on its complete inappropriateness to the question.
I meant -p, but wrote -r,  ... not once, but three times.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.