Move wordpress website between VPS fastest with SSH

Maybe at any time you want to deal with vps, move or copy a web site from one server to another, which is the fastest way? It is possible to use the Plugin, but if you have large data of 1gb or more then using the plugin is not very feasible…

If you have full control over your vps (root) then follow the steps below. Suppose you want to transfer wordpress from domainA.com on VPS A to domainB.com on VPSB, the vps are ready to work with wordpress. for example, installed webinoly.

Step 1: Create a new website on VPS B

SSH to VPS B

Create website wordpress domainB.com on VPS B, for example, done with webinoly

sudo site domainB.com -wp -cache=on
sudo site domainB.com -ssl=on #nếu muốn tạo ssl

Then go to Phpmyadmin and delete all the database tables that domainB.com just created (because I don’t know the command to delete all the tables, I go to phpmyadmin to delete: D). We get empty data, for example dbdomainB

Step 2: Back up the code and database on VPS A

Backup wp-content folder

SSH to VPS A, cd to wp-content folder and compress with the following command:

cd /var/www/domainA.com/htdocs/wp-content/
tar -zcvf wp-content-A.tar.gz *

We have file wp-content-A.tar.gz located in the directory wp-content

Backup database

Open file wp-config.php find the line define('DB_NAME', 'dbdomainA'); to see database name.

Export database:

mysqldump dbdomainA > dbdomainA-backup-file.sql

We have data file dbdomainA-backup-file.sql located in the root directory.

Step 3: Copy Backup files to VPS B

Copy file wp-content-A.tar.gz to VPS B:

scp /var/www/domainA.com/htdocs/wp-content/wp-content-A.tar.gz root@ip-vps-B:/var/www/domainB.com/htdocs/wp-content

Copy file dbdomainA-backup-file.sql to VPSB:

scp /root/dbdomainA-backup-file.sql root@ip-vps-B:/root

Note:

  • Replace the file and path with your own executable
  • ip-vps-B is the ip address of VPS B
  • After executing the above command, there will be questions to confirm yes or no, just enter yes and press enter. then enter Password root account of VPS B.

Step 4: Extract and Import database

Now go back to VPS B. Go to wp-content folder and extract the copy file:

cd /var/www/domainB.com/htdocs/wp-content/ 
tar -xvf wp-content-A.tar.gz

Import the data file dbdomainA-backup-file.sql just copied into the data dbdomainB

cd
mysql dbdomainB < dbdomainA-backup-file.sql

Step 5: Done

Now visit domainB.com to see the results.

We will be happy to hear your thoughts

Leave a reply

DATVNN.COM
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart