Migrate existing website to Kinsta

Make snapshot on current website

  • Install BackupBuddy on existing website
    • Set error notifications to support@anchor.host and uncheck to dump database into single file.
    • Run full website backup
  • Copy snapshot url in and modify in following format to use in below script:
    https://anchor.host/wp-content/uploads/backupbuddy_backups/backup-anchor_host-2018_01_04-09_14pm-full-6d5h69dm8s.zip

Migrate existing website to Kinsta

function anchor_kinsta_migrate {
  read -p $'\e[31mBackup Snapshot\e[0m: ' backupsnapshot
  backupformat=`echo $backupsnapshot | perl -n -e '/.+\.(.+)/&& print $1'`
  cd private
  wget $backupsnapshot
  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`
  rm -rf ~/public/wp-content/uploads
  mv $wordpresspath/uploads ~/public/wp-content/
  for d in $wordpresspath/themes/*/; do
    mv $d ~/public/wp-content/themes/
  done
  for d in $wordpresspath/plugins/*/; do
    mv $d ~/public/wp-content/plugins/
  done
  cd ~/public
  wp plugin delete wp-super-cache adminer wordfence w3-total-cache wp-file-cache broken-link-checker yet-another-related-posts-plugin comet-cache-1 woothemes-updater ewww-image-optimizer https-redirection really-simple-ssl hello wordpress-php-info force-strong-passwords
  cat ~/private/$wordpresspath/../wp-config.php | grep "DB_NAME"
  rm -f ~/public/wp-content/advanced-cache.php
  rm -f ~/public/wp-content/object-cache.php
  cd ~/public/
  find . -type d -exec chmod 755 {} \;
  find . -type f -exec chmod 644 {} \;
  chmod 600 ~/public/wp-content/mysql.sql
  database_files=`find wp-content/uploads ~/private/ -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
  siteurl=`wp option get siteurl`
  siteurlhttp=${siteurl/https:/http:}
  wp search-replace $siteurl $siteurlhttp --all-tables
  wp rewrite flush
}
anchor_kinsta_migrate

After DNS and https installed run the following

siteurl=`wp option get siteurl`
siteurlhttps=${siteurl/http:/https:}
wp search-replace $siteurl $siteurlhttps --all-tables
wp rewrite flush