User Tools

Site Tools


computing:migratewp

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
computing:migratewp [2019/06/16 05:50] 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 Firstcompletely set up LAMP and TLS and DNS, etc., before you begin migration, and review [[https://jonathanhaack.com/dokuwiki/doku.php?id=computing:apachesurvival|Apache Survival]] if you are unclear on how to do that Nowonce that is set up, authenticate as root on the //old host// and backup your entire database (thanks to @jjscha for this mysqldump syntax):+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 caseI 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:
  
-Use scp to get the file to the new host:+  mysqldump -u root -p --all-databases > all_databases.sql
      
-  sudo scp mysqldump-all-databases.sql user@newhostorip.com:+Once that's done, send the ''.sql'' file over to the target host as follows: 
 +   
 +  scp all_databases.sql root@targethost.com
 +   
 +Now, ssh into the target host and import the databases as follows:
  
-Now, time to import that database into the new host:+  mysql -u root -p < /root/all_databases.sql
  
-  mysql -u user -h localhost -p < /path/to/mysqldump-all-databases.sql +After the database is migrated, simply copy all the files from web root for the instance over to the new hostEnsure 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:
-   +
-This will take some time Once it finisheslog into the mysql command mode and verify the databases made it over:+
  
-  sudo mysql -u user -p +    DROP DATABASE olddb
-  > SHOW DATABASES+    DROP USER 'olddbuser'@'localhost';
-  > EXIT+
  
-Run this command on both machinesand the output should be identical Nowit is time to migrate the website //files// over to the new host:+In cases of large databasesyou might get an error that the shell lost connection to the database or that it vanished, etcIn that caseadjust your packet and timeout settings:
  
-  sudo scp -r /var/www/website.com/public_html user@newhostorip.com:/var/www/newwebsite.com/ +  nano /etc/mysql/mariadb.conf.d/50-server.cnf 
-   +  <wait_timeout = 28800> 
-Put the files in the appropriate locations, and that should be it.  Definitely reboot, and I have found it is helpful to restart the router, modem, and workstations on the network.  If the old host is on the same network, this is helpful.+  <interactive_timeout = 28800> 
 +  <max_allowed_packet=2G>
  
- --- //[[netcmnd@jonathanhaack.com|oemb1905]] 2019/06/15 23:42//   + --- //[[jonathan@haacksnetworking.org|oemb1905]] 2022/09/03 17:10//
-  +
computing/migratewp.1560664254.txt.gz · Last modified: 2019/06/16 05:50 by oemb1905