I migrated a WordPress site from an old server to a new server, so I’ll roughly introduce the procedure.
Work on Source Server
Dump from MySQL
mysqldump --default-character-set=binary -h localhost -u dbuser -p dbname > backup.sql
Backup WordPress Content
Next, compress the contents directory below the wordpress content placed in /var/www/vhosts/codenote.net with tar.
cd /var/www/vhosts/
tar zcvf codenote.net.tar.gz codenote.net/
Transfer Files from Source Server to Destination Server
Transfer backup.sql and codenote.net.tar.gz to the destination server.
Work on Destination Server
Create Database for WordPress
# mysql -u root
mysql> create database dbname;
mysql> grant all on dbuser.* to dbname@localhost identified by 'mypassword';
MySQL Restore
mysql -u dbuser -p dbname < backup.sql
Deploy WordPress Content
Extract the backed up WordPress content compressed file under /var/www/vhosts/.
cd /var/www/vhosts/
tar zxvf codenote.net.tar.gz
As a precaution, make all owners the same as the web server user.
chown -R nginx. /var/www/vhosts/codenote.net
That’s all from the Gemba.
