Backup and restore data between linux VPS and of website migration tutorials

  • 2020-05-07 20:48:14
  • OfStack

The commands Debian and CentOS used in this article are common, and the file directory is the same as LNMP by default, please modify accordingly.

For example, www.xxx.com is bound to wwwroot directory of VPS1

Data packaging (backup) on 1.

a. VPS1 file data package (Tar command explanation / / www. ofstack. com/os/RedHat / 1219. html)

cd /home/wwwroot/
tar zcvf xxx. tar. gz site directory (such as/home wwwroot/vmvps. com)

MySQL data export on VPS1

mysqldump-u username -p password database name > xxx.sql

Data transfer (recovery) on 2.

Data recovery on a.VPS2 (wget retrieves remote files)

cd /home/wwwroot/
wget http: / / www. xxx. com/xxx tar. gz (get) file from the VPS1
tar zxvf xxx.tar.gz

MySQL data import on b.VPS2

* please first create the corresponding database and user (same as the original database and user) in phpmyadmin.

wget http://www.xxx.com/xxx.sql
mysql-u your new username -p username password the database name you just created < xxx.sql

This is the end of the article, hope to help you ~ also welcome to point out the mistakes!

Related articles: