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
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-config.php find the line
define('DB_NAME', 'dbdomainA'); to see database name.
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
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
yesand press enter. then enter
Passwordroot 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
cd mysql dbdomainB < dbdomainA-backup-file.sql
Step 5: Done
Now visit domainB.com to see the results.