User Tools

Site Tools


computing:migratewp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
computing:migratewp [2019/02/18 05:45] – created oemb1905computing:migratewp [2022/09/03 23:11] (current) oemb1905
Line 11: Line 11:
 ------------------------------------------- -------------------------------------------
  
-This tutorial is designed to step one through how to migrate a self-hosted Word Press site manually Firstauthenticate as root on the //old host// and backup your entire database.+This tutorial is designed to step one through how to migrate a mysql database to another hostThe tutorial is named migratewpbecause I first did this on a WP instanceIn my case, I have cron jobs that run mysqldump nightly as follows:
  
   sudo -i   sudo -i
Line 29: Line 29:
   --routines          \   --routines          \
   > mysqldump-all-databases.sql   > mysqldump-all-databases.sql
 +  
 +But if you don't have that, then just make a backup of the database on the source host as follows:
  
-The spacing is optional and thanks to @jjscha for providing a great template to use.  This can and should be used as a backup script.  You can find the latest version [[https://codetalkers.services/oemb1905/hackingclub/blob/master/nixnscripts/backup_mysql.sh|mysql-backup.sh]].  Now that your database is secure, let's import that database into the //new host// as follows: +  mysqldump -u root ---all-databases > all_databases.sql
- +
-  mysql -u user -h localhost -p < /path/to/mysqldump-all-databases.sql+
      
-This will take some time.  Once it finisheslog into the mysql command mode and verify the databases made it over:+Once that's done, send the ''.sql'' file over to the target host as follows: 
 +   
 +  scp all_databases.sql root@targethost.com: 
 +   
 +Nowssh into the target host and import the databases as follows:
  
-  mysql -u user -p +  mysql -u root -p < /root/all_databases.sql
-  > SHOW DATABASES; +
-  > EXIT+
  
-Run this command on both machines, and the output should be identical.  Now, it is time to migrate the website over:+After the database is migrated, simply copy all the files from web root for the instance over to the new host. Ensure that permissions, configuration files, certificates, etc., are appropriately configured, and then reboot. If any databases came over, but you no longer need them, you can drop them and the users as follows:
  
-  scp -r /var/www/website.com user@newhost.com: +    DROP DATABASE olddb; 
-   +    DROP USER 'olddbuser'@'localhost';
-Put the files in the appropriate locations, obviously make sure you set up TLS again if needed and check file permissions for the directories, but that should be it.  Your WP website is now on the new host.  Of course, also make appropriate DNS / port forwarding adjustments so that the new website is accessible.+
  
- --- //[[netcmnd@jonathanhaack.com|oemb1905]] 2019/02/17 22:06// +In cases of large databases, you might get an error that the shell lost connection to the database or that it vanished, etc. In that case, adjust your packet and timeout settings: 
-   + 
-  +  nano /etc/mysql/mariadb.conf.d/50-server.cnf 
 +  <wait_timeout = 28800> 
 +  <interactive_timeout = 28800> 
 +  <max_allowed_packet=2G> 
 + 
 + --- //[[jonathan@haacksnetworking.org|oemb1905]] 2022/09/03 17:10//
computing/migratewp.1550468741.txt.gz · Last modified: 2019/02/18 05:45 by oemb1905