Issue:
How do I copy file and directories across to another server and preserve symlinks?
Resolution:
In order to preserve symlinks whilst copying files and directories across a network the use of the rsync command is recommended. If scp is used this will actually copy the symlinked file to the remote directory and lose the link relationship.
For example below we want to copy and preserve the symlink relationship between test.log and /home/test/test.log in the local /rsync_test directory to machine serverOne's /rsync_test directory.
Two test cases will be used below to illustrate the point.lrwxrwxrwx 1 root root 5 Jan 19 15:11 test.log -> /home/test/test.log
USING SCP
Listing the rsync_test directory on machine serverOne shows the following:scp /rsync_test/* serverOne:/rsync_test/
-rw-r--r-- 1 root root 5 Jan 19 15:11 test.log
In this example scp copied the actual test.log file to the destination directory, therefore losing the symlink relationship.
USING RSYNC
Listing the rsync_test directory on machine serverOne shows the following:rsync -a -e ssh /rsync_test/ serverOne:/rsync_test
In this example the symlink relationship has been preserved.lrwxrwxrwx 1 root root 5 Jan 19 15:11 test.log -> /home/test/test.log
From the output above you can see rsync can preserve symlink status and scp can not. For further information see man rsync and man scp.
------------------------
Best Regards,
eUKShane
http://www.eukhost.com



LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks