Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

why scp command not copy links from local copmuter to other ( how to copy the links)

as

 scp -rp dir linux:/dir_target

remark in dir I have files and links

share|improve this question
    
are both computer are linux and those are symbolic links ? –  Matthieu Jan 14 '11 at 4:34
    
dir have simbolic links –  jennifer Jan 14 '11 at 5:54

2 Answers 2

up vote 3 down vote accepted

If I understand what you want correctly. You want to exactly mirror dir on the local machine to dir_target on linux, and it is copying the contents of the symlink, rather than copy the symlink itself. To make an exact duplicate, you need to use rsync instead of scp.

rsync -Wav --progress dir linux:dir_target

I suspect that will have the desired result. I generally use rsync anyway because it will only copy files that need to be copied, and generally is more intelligent than scp.

share|improve this answer

This is a good question. Unfortunately, scp does not copy symlinks, and it looks as if there are no plans to add it: https://bugzilla.mindrot.org/show_bug.cgi?id=485.

However, alternatives do exist. You could:

  • Use tar cvfz to compress the folder (tar will preserve the links); then scp the tar file
  • Use the rsync -e ssh switch to sync over ssh (for example rsync -ave ssh /src/dir user@hostname:/folder)
  • Use a command like this to find and list symlinks, then re-create them on the other side (not great, but I considered implementing this myself):

    ls -la `find openddr_ODRINT1/ -type l`

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.