logoquicktiger.net - Kind of Tipster Blog :-)


How to Back up and Transfer Php, Mysql sites to another server

Posted in How to by admin on the June 27th, 2008

Prep

The most important thing is keep your old site after everthing is done well. You need a ssh client program to do this backing up and moving.You can download the program below.

Putty

Backing up Mysql

There could be a problem if you back up your database file via Phpmyadmin. Therefore I suggest you to use ssh client program to back up mysql database. Additionally, If you have a big mysql database you definitely have to use SSH to back up.

After connect to the ssh server of your web site. You should type this command to the console.

mysqldump add-drop-table -h SERVER -u DBUSERNAME -pPASSWORD DATABASENAME > db.sql

# -p is adjacent with PASSWORD.

After that, in the root path of the site. Write this code to SSH screen.

tar cvf backup.tar .

Than we have to move backup.tar to accessible directory on the ftp(Like public_html, httpdocs). The next step is getting the backup file from old server to new server.

Transfer to New Server

It’s the first thing to do on the below that we have to do is in new server.

wget http://www.example.com/backup.tar

After this we will get the our backup file to new server. We have to extract files the code is on the below.

tar -xpf backup.tar

Now, we have files and database. We need to dump database file. We will use this code.

mysql -h SERVER -u DBUSERNAME -pPASSWORD DATABASENAME < db.sql

We transferred our files and mysql backup to new server. The last thing you have to do is set up the config file.

Tips ;

Do not forget to remove or move to inaccessiable directory your backups.

Server is which we have used to backup and dump database is usually localhost.