Question : How do I copy website files and their modes(drwx) from one Linux box to another?

I need to move a website from one Linux box to another.

I would like to recursively copy the files and directory structure from the html directory on the old server to the appropriate directory on the new server maintaining all of the file and directory attributes as there are a lot of perl scripts involved. I would also like to keep the file create/modified timestamps as well.

I have root access to both machines via SSH. Both machines are located in the same data center (The Planet).

How do I do this from my SSH command prompt?


Source Box
IP=x.x.x.x
OSTYPE=linux-gnu
MACHTYPE=i386-redhat-linux-gnu
uname -a=Linux ensim.xxx.com 2.6.9-55.0.2.ELsmp #1 SMP Tue Jun 12 17:59:08 EDT 2007 i686 i686 i386 GNU/Linux
ControlPanel=Ensim Pro X
Source directory=/home/virtual/site1/fst/var/www/html
The files here are owned by owner:group = admin1:admin1
Some Joomla related files are owned by apache:apache
There is an apache:apache user/group on both machines

Destination Box
IP=y.y.y.y
OSTYPE=linux-gnu
MACHTYPE=i686-redhat-linux-gnu
uname -a=Linux plesk.xxx.com 2.6.18-194.3.1.el5PAE #1 SMP Thu May 13 13:48:44 EDT 2010 i686 i686 i386 GNU/Linux
ControlPanel=Plesk 9.4
Destination directory=/var/www/vhosts/mydomain.com/httpdocs
The files here should be owner:group = myuser:psacln or apache:apache

Answer : How do I copy website files and their modes(drwx) from one Linux box to another?

The plain copy action is easy:

At the source box command prompt, type

cd /home/virtual/site1/fst/var/www/html
tar -czpf web_site_files.tar.gz *

Assuming, you don't log in as root but as a user and then su to root...

scp web_site_files.tar.gz [email protected]:


Now, at the destination box command prompt:

su - root
cd /var/www/vhosts/mydomain.com/httpdocs

tar -xzpf ~user/web_site_files.tar.gz
chown -R apache:apache *

Keep in mind, though, that this might not work right of the bat. Your environment might need more configuration.
Random Solutions  
 
programming4us programming4us