Tuesday, November 14, 2017

The following script may help you to transfer or mirror your existing PHP+MySQL website completely from one server to another. You will need SSH accounts on both servers, with public key authentification set up (server 2 has public key in its ~/.ssh/authorized_keys for corresponding server 1's ~/.ssh/id_dsa (id_rsa)  ).

Save the following script as ~/transfer-site.sh, make it executable (chmod +x ~/transfer-site.sh) and launch it on server 1:

#!/bin/sh echo "Starting syncronization..." echo "Starting file transfer" rsync -rvz -e 'ssh -p 22' /PATH/TO/YOUR/EXISTING/SITE/ This email address is being protected from spambots. You need JavaScript enabled to view it.:/PATH/TO/YOUR/NEW/SITE/ --exclude="configuration.php" echo "Starting MySQL transfer" mysqldump --add-drop-table -u dbuser_1 -h mysql.example.com database_1 -pPASSWORD1 | ssh new-server mysql -h mysql.example.org -u dbuser_2 -pPASSWORD2 database_2 echo "All done!"

Is is assumed that you are transferring data from server 1 (example.com) to server 2 (example.org). And, sure, you do not need --exclude="configuration.php" in most cases. This will be useful only if you are synchronizing master Joomla! website with its mirror.

 

To use

ssh new-server

syntax you will need add the following to your ~/.ssh/config:

Host new-server Hostname example.org User username Port 22 PasswordAuthentication no
Published in Linux, BSD, Unix

Welcome!

Here I publish articles related to my areas of interest, my brief notes that may save some time to others, as well as some of my works.

This site is a work in progress. I will add more sections in the future, such as

  • More photos to photogallery
  • More Joomla!-related articles
  • ...

 

themeforest

New Posts

Using dynamic GeoIP module with nginx (CentOS)

nginx introduced dynamic module support in v. 1.9.11. This brief article provides step-by-step procedure...

13-04-2016 in Linux, BSD, Unix

READ MORE

Visual difference between pseudo and true random data

This is is "random" image generated using PHP rand() function: And this is an image...

20-11-2015 in Blog

READ MORE

Best EEPROM practices

(this article is a work in progress). My own advice will be added later...   Having...

12-10-2015 in Arduino

READ MORE
Scroll to top

We use cookies, just to track visits to our website, we store no personal details Privacy policy