Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 337
hozza Avatar asked Jan 16 '23 23:01

hozza


2 Answers

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
like image 147
lunixbochs Avatar answered Mar 04 '23 03:03

lunixbochs


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.

like image 23
Rory Hunter Avatar answered Mar 04 '23 03:03

Rory Hunter