Powered by eUKhost®

Announcement

Collapse
No announcement yet.

Copy file and directories across to another server and preserve symlinks...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy file and directories across to another server and preserve symlinks...

    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.

    lrwxrwxrwx 1 root root 5 Jan 19 15:11 test.log -> /home/test/test.log
    Two test cases will be used below to illustrate the point.

    USING SCP

    scp /rsync_test/* serverOne:/rsync_test/
    Listing the rsync_test directory on machine serverOne shows the following:

    -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

    rsync -a -e ssh /rsync_test/ serverOne:/rsync_test
    Listing the rsync_test directory on machine serverOne shows the following:


    lrwxrwxrwx 1 root root 5 Jan 19 15:11 test.log -> /home/test/test.log
    In this example the symlink relationship has been preserved.

    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

    Best Regards,
    Sebastian
    Senior System Administrator

ban-img
Working...
X