Wednesday, February 11, 2009

How To Migrate Sites from one site to another site

Migrating a site from one server to another server has been confirmed by following steps:

  • Copying site contents, such as files into one server to another server

  • Making Database backup and copy the backup SQL file from one one server to migrating server
  • Restoring Database and creating DB user with necessary privileges
  • Creating Virtual Host for the migrating site into desired server
  • Testing the site by setting desired server's IP into local machines hosts file.
  • Confirming migration completion and request to set the IP to the desired server.

Copying site contents, such as files into one server to another server
Using rsync command:

rsync -avh -e ssh root@source_server_ip:~/source_directory ~/destination_directory

This command will prompt for a password, here it will prompt for root password

Using scp command:

scp -r root@source_server_ip:~/source_directory ~/destination_directory

This command will prompt for a password, here it will prompt for root password


Note: Copying Site contents made by rsync command and database SQL backup files have been copied by scp command.Making Database backup and copy the backup SQL file from one one server to migrating server:

Following command has been used frequently in database backup into *.sql files.

mysqldump -u root -p db_name > db_name.quick.sql

This will prompt root password


Note: Each database back up in sql has been stored into ~/backup_db directory


Restoring Database and creating DB user with necessary privileges:

Following process has been followed for this step:
  • Creating the database using create
    database db_name
  • Dumping database using
    mysql -u root -p db_name < db_name.quick.sql
  • Creating DB user, DB pass and setting necessary privileges with the following command :
    grant all privileges on db_name.* to 'user_name'@'hostname' identified by 'db_pass';
  • Flush privileges using :
    flush privileges;
Creating Virtual Host for the migrating site into desired server
To do this the following file needs to be edited.

vi /etc/httpd/conf.d/vhosts.conf

Testing the site by setting desired server's IP into local machines hosts file.

This is done by following steps
  • edit this file:
    vi /etc/hosts
  • put following in that file on local machine:
    desired_server_ip testing_site
    Example: 123.49.47.12 grameenamerica.com
  • See each functions are OK for the domain coming from that IP. If OK then migration is successful.

Confirming migration completion and request to set the IP to the desired server.

After testing it is confirmed that migration is successful, then requesting the supervisor to

set the desired/migrated host's IP for the domain.

No comments:

Post a Comment