Why does the
scp command not copy links from the local computer to the other?
scp -rp dir linux:/dir_target
How can I copy the links when in the source directory I have both files and links?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.
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:
tar cvfzto compress the folder (tar will preserve the links); then scp the tar file
rsync -e sshswitch 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`