hozza
hozza

Reputation: 630

How do I copy symbolic links between servers?

We are moving web servers. (LAMP)

Webserver 1 has hundreds of symbolic links pointing to files in a different directory (eg. ../../files/001.png). When we move over to the new server (have downloaded the site to my computer then reuploading to Webserver 2 using SFTP client Transmit). It does not copy the symbolic links...

Is there a better way to get the symbolic links from one server to another apart from recreating them on the new server?

Upvotes: 4

Views: 6930

Answers (2)

lunixbochs
lunixbochs

Reputation: 22415

rsync -a from one server to another will preserve file attributes and symlinks.

rsync -av user@server:/path/to/source user@server2:/path/to/target

Upvotes: 5

Rory Hunter
Rory Hunter

Reputation: 3460

Something like the following? On Webserver 1:

tar czf - the_directory | (ssh Webserver2 "cd /path/to/wherever && tar xzf -")

This creates a tar of the stuff to copy to STDOUT, and pipes it to an untar on the other server over ssh. It can be faster than a recursive ssh copy too.

Upvotes: 4

Related Questions