Migrating Wordpress Websites

Posted Thursday, December 29, 2022 by Sri. Tagged MEMO
EDITING PHASE:gathering info...

I again find that I have to move my wordpress site from one server architecture to another. I think I'll do this in two stages:

  • Download MAMP Pro to M1, Register
  • Set up Dev Environment
  • Backup Files
# backup wp-content 
tar -cvzf 00-wp-content.tar.Z wp-content/plugins/* wp-content/themes/* wp-content/uploads/*

# backup root directories and identifying files
tar cvf 00-root-dirs.tar _archive/* favicon.ico googleef5a1b1becdb2da4.html googlehostedservice.html images/* information/* jobs/* pinterest-50ce2.html pinterest-fd0f9.html _PRINT_JOBS/* robots.txt tools/* _xcom/*

# backup wordpress files, including .htaccess w/ redirects
tar cvf 00-wp-dirs.tar .htaccess pub/* pub-guest/* _wpcontent/*

# backup _wp_content
tar -cvzf 00_wp_content.tar 

# backup database
mysqldump -u{username} -p{password} -hlocalhost dscom_wpsys > wp-dscom-wpsys.sql
compress wp-dscom-wpsys.sql

Where did I leave off? Installing WP on Opalstack. I tried to use the default setup, but have switched to PHP+Apache

  • The default password for MariaDB user db_user is db_password
  • The name of the db is db_name

DAY 1

Backup Files Manually

This is just good practice to know how to do it. We'll be using these files when copying from the ORIGIN to the NEWHOST, but for LOCAL we'll be using Updraft to do initial testing

Make Tarballs for Site Files

# backup root site dirs and fingerprint files, root htaccess redirectors
tar -cvzf 00-root-dirs.tar.Z favicon.ico images/*  robots.txt tools/* _xcom/* .htaccess index.php

# backup root content including .htaccess w/ redirects
tar -cvf 00-root-content.tar pub/* pub-guest/* _wpcontent/* _archive/* information/* jobs/* _PRINT_JOBS/*

# backup wordpress wp-content from root/wordpress_subdir
tar -cvf 00-wp-content.tar wp-content/plugins/* wp-content/themes/* wp-content/uploads/*

MySQLDump Wordpress Database

# backup database
mysqldump -u{username} -p{password} -hlocalhost dscom_wpsys > wp-dscom-wpsys.sql
compress wp-dscom-wpsys.sql
  • origin host: pull username, password from wp-config.php
  • origin host: run
  • on new host: create database, username, userpassword, and give access to localhost only for everything except GRANT
  • purchase Updraft Migrate plugin (terrible package)
  • install wordpress on new host, upload Updraft Migrate plugin
  • make backup on

Gather Downloads

  • Download MAMP Pro to M1, Register
  • Download Wordpress installer files
  • Download the Updraft with Migrate package ($30) zip'd plugin
  • Copy tarballs to LOCAL Migration folder

Create MAMP Pro LOCAL test install

Note: MAMP defaults to ~/Sites for its hosts.

Next pull information needed and create the local site

  • from ORIGIN: Pull the database db_name, db_user and db_pass from wp-config.php
  • LOCAL MAMP: create davidseah.local host (will be in ~/Sites/davidseah.local)
  • _make sure that MAMP has the ability to modify your /etc/hosts file and adds davidseah.local so you can browse to it. It will have a port also like 8890 which you can change
  • LOCAL MAMP: add user db_user with db_pass and grant all permissions EXCEPT grant
  • LOCAL: copy Wordpress installer zip to LOCAL HTTPDOCS, uncompress into subdir to mirror how ORIGIN is set up. The default I use is sys

Do the initial local Wordpress setup

  • browse to MAMP davidseah.local:8890/sys
  • fill-in the 5-minute install dialogs
  • write down new password and login to LOCAL

Get the Updraft Backups from ORIGIN

  • they're located in wp-content/updraft on the ORIGIN
  • copy them to the LOCAL setup under wp-content/updraft
  • LOCAL: login to Wordpress and go to PLUGINS, then ADD NEW and UPLOAD updraftplus-with-migrator.2.22.25.zip

Note: the migrator package doesn't actually indicate that it is special in anyway, and will actually warn you that it doesn't handle migrations when it actually seems to work...I think. It's dumb.

  • Migrate/Restore the backup from the copied LOCAL setup. You might have to "rescan" directories
  • delete wordfence, log-me-in plugins afterwards!

Getting the rest of it working

  • restore tar xvzf 00-root-dirs.tar.Z in root (not wordpress subdir)
  • restore tar xvf 00-root-content.tar in root
  • restore tar xvf 00-wp-content.tar in wordpress subddir/wp-content

To setup root/_wpcontent on LOCAL, can also symbolic link to the main DROPBOX backup:

cd <ROOT DIR>
ln -s ~/Desktop/Dropbox/@SRI-PROJECTS/@DavidSeahCom/.../httpdocs-synced/_wpcontent

The LZIL plugin needs some paths updated too. It's in wp-content/themes/[filename-redacted] around line 338:

# GET BASE PATHS
// $upload_path = get_settings('fileupload_realpath');
// $upload_url = get_settings('fileupload_url');

if ( array_key_exists('HTTPS',$_SERVER) ) {
$protocol = ($_SERVER['HTTPS'] != "on") ? 'http://' : 'https://';
} else {
$protocol = 'https://';
}
$upload_url = $protocol . 'davidseah.local:8890/_wpcontent';
if ($local_dev) {
$upload_path = '/Users/username/Sites/davidseah.local/_wpcontent';
$upload_url = $protocol . 'davidseah.local:8890/_wpcontent';
} else {
$upload_path = '/Users/username/Sites/davidseah.local/_wpcontent';
$upload_url = $protocol . 'davidseah.local:8890/_wpcontent';
}

Troubleshooting: Links go to Wrong Server

You might have to update the WordPress Home and SiteURL at: wp-admin/options-general.php. You may have to set the following strings in wp-config.php if links are broken (due to a bad migration), like so:

define( 'WP_HOME', 'https://davidseah.local:8890' );
define( 'WP_SITEURL', 'https://davidseah.local:8890/sys' );

You might have to update them through MySqlAdmin by editing the options table.

NEXT STEPS DEC 31

What got done?

  • installed davidseah.local on mac, grabbed downloads
  • need to transcript DNS settings

MEDIA TEMPLE DNS

(various subdomain A records)
(various CNAME records for heroku, shopify, github, auth)

(standard gmail aspmx MX records)

(various TXT records for SPF, DKIM, DMARC)
  • scratch notes

setting up opalstack wordpress

  • using their built-in installer is not flexible enough

  • site: staging-davidseah

  • app: php-davidseah-com is a "php 7 fpm apache" application (php 8 incompatible)

  • domain: staging.davidseah.com

  • maria db: db_name

  • maria db user: db_user@opalstack.com

  • maria db pass: db_password

wordpress configuration:

  • upload zip, unzip into folder and rename it to sys
  • getting through the config, left-off @opalstack.com for db user on this host to make it work
  • get new username and password from Notification log.

copying tar files scp 00-* username@opalstack.com:/home/username/apps/wp-app

u: `opal_user`
p: `opal_password`
* The default password for MariaDB user is found in the Notification Log on Opalstack Dashboard
* The name of the db created is also in the notification log

Used the UPDRAFT migrator and it worked. Now restoring

  • 00-root-content
  • 00-root-dirs
  • 00-wp-content

DELETE plugins temporarily so can access

  • wordfence
  • hide-login

LZIL requires changes to

  • $local_dev value should be current host domain (e.g. opalstack-example-host.com)
  • change path $upload_path and $upload_url to match staging server (local MAMP install)