Migrate existing website to WP Engine

Depending on the type and size of website will determine which migration process to use.

Migrating small websites with infrequent changes

  • Install BackupBuddy on existing website
  • Set error notifications to support@anchor.host and uncheck to dump database into single file.
  • Run full website backup, download and extract. (or directly migrate with the format: http://anchor.host/wp-content/uploads/backupbuddy_backups/backup-anchor_host-2018_01_04-09_14pm-full-6d5h69dm8s.zip)
  • Prep new install
  • Upload themes, plugins and upload folders
  • Database import over WP Engine’s phpMyAdmin.
  • Run install script to install Anchor plugins and backup newly migrated site

Migrating large websites over SSH

# Check local free space
df -h

# Check folder size to make sure there is enough local storage to make a tar
du -sh ~/domains/midwaychurch.net/

function anchor_wpengine_migrate {
  backup_date=$(date +'%Y-%m-%d')
  domain=`wp option get home`   #captures current url
  domain=${domain/http:\/\//}   #removes http://
  domain=${domain/https:\/\//}  #removes https://
  current_folder=${PWD##*/}
  wp db export --skip-plugins --skip-themes --add-drop-table - > wp-content/mysql.sql
  chmod 600 wp-content/mysql.sql
  cd ..
  tar -cvzf $domain-$backup_date.tar.gz $current_folder/ --exclude .git
  mv $domain-$backup_date.tar.gz $current_folder/
  cd $current_folder
  ls $domain-$backup_date.tar.gz
}
anchor_wpengine_migrate

# Download tar locally
scp midwaychurch.net@s186773.gridserver.com:~/domains/midwaychurch.net-2016-11-01.tar.gz ~/Desktop/
  • Upload contents of `/wp-content/uploads/`, `/wp-contents/themes/` and `/wp-content/plugins/` to new server over sFTP
  • Upload any non-WordPress files in the root to the server over sFTP
  • Import database

Migrating WordPress site to WP Engine over SSH (Pulling Down)

function anchor_wpengine_migrate {
    cd ~/sites/*
    wordpress_path=`pwd`
    backup_url=$1
    mkdir _wpeprivate/restore
    cd _wpeprivate/restore
    if [[ "$backup_url" == *"admin-ajax.php?action=pb_backupbuddy_backupbuddy&function=download_archive&backupbuddy_backup"* ]]; then 
        echo "Backup Buddy URL found"; 
        backup_url=${backup_url/wp-admin\/admin-ajax.php?action=pb_backupbuddy_backupbuddy&function=download_archive&backupbuddy_backup=/wp-content\/uploads\/backupbuddy_backups/}
    fi
wget $backup_url
if [[ "$backup_url" == *".zip" ]]; then 
    unzip *.zip
fi
if [[ "$backup_url" == *".gz" ]]; then 
    tar xvzf *.gz
fi
if [[ "$backupformat" == *".tar" ]]; then 
    tar xvzf *.tar
fi
wordpress_restore_path=`find * -type d -name 'wp-content' -print -quit`
rm -rf $wordpress_path/wp-content/uploads/
mv $wordpress_restore_path/uploads $wordpress_path/wp-content/
for theme in $wordpress_restore_path/themes/*/; do
    rm -rf $wordpress_path/wp-content/themes/${theme##*themes/}
    mv $theme $wordpress_path/wp-content/themes/
done
for plugin in $wordpress_restore_path/plugins/*/; do
    rm -rf $wordpress_path/wp-content/plugins/${plugin##*plugins/}
    mv $plugin $wordpress_path/wp-content/plugins/
done
cd $wordpress_path
wp plugin delete wp-super-cache adminer wordfence w3-total-cache wp-file-cache broken-link-checker yet-another-related-posts-plugin force-strong-passwords
database_files=`find wp-content/uploads _wpeprivate/restore -type f -name '*.sql'`
database_files="$database_files Skip"
PS3="Select database file: "
select database in $database_files; do
    if [ -n "$database" ]; then
        database_file=${database}
    fi
    break
done
if [[ "$database_file" != "Skip" ]]; then
    wp db reset --yes
    wp db import $database_file
fi
}
# anchor_wpengine_migrate ""

Migrating WordPress site to WP Engine over SSH (Local Snapshot)

cd sites/*
mkdir _wpeprivate/restore
cd _wpeprivate/restore #put snapshot here

function anchor_wpengine_migrate {
  backupformat=`find * | perl -n -e '/.+\.(.+)/&& print $1'`
  if [[ "$backupformat" == "zip" ]]; then 
    unzip *.zip
  fi
  if [[ "$backupformat" == "gz" ]]; then 
    tar xvzf *.gz
  fi
  if [[ "$backupformat" == "tar" ]]; then 
    tar xvzf *.tar
  fi
  wordpresspath=`find * -type d -name 'wp-content' -print -quit`
  mv $wordpresspath/uploads ../../wp-content/
  for d in $wordpresspath/themes/*/; do
    mv $d ../../wp-content/themes/
  done
  for d in $wordpresspath/plugins/*/; do
    mv $d ../../wp-content/plugins/
  done
  cd ../..
  wp plugin delete wp-super-cache adminer wordfence w3-total-cache wp-file-cache broken-link-checker yet-another-related-posts-plugin force-strong-passwords
  database_files=`find wp-content/uploads _wpeprivate/restore -type f -name '*.sql'`
  database_files="$database_files Skip"
  PS3="Select database file: "
  select database in $database_file; do
    if [ -n "$database" ]; then
        database_file=${database}
    fi
    break
  done
  if [[ "$database_file" != "Skip" ]]; then
    wp db reset --yes
    wp db import $database_file
  fi
}
anchor_wpengine_migrate