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 on VPS A to on VPSB, the vps are ready to work with wordpress. for example, installed webinoly.

Step 1: Create a new website on VPS B


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

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

Then go to Phpmyadmin and delete all the database tables that 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/
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/ root@ip-vps-B:/var/www/

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

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


  • 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/ 
tar -xvf wp-content-A.tar.gz

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

mysql dbdomainB < dbdomainA-backup-file.sql

Step 5: Done

Now visit to see the results.