Migration SOP

Website migration presents a dual aspect. Its outcome hinges upon the precautionary measures undertaken, the chosen migration methodology, and the thoroughness of post-migration quality assurance protocols.

General Notes

  1. Discourage search engines to index the staging site and encourage them to index the live website.
  2. Maintenance mode must be active on both the staging and production sites.
  3. In any backup method, we must retain up to only three latest backups, except server tools.

Pre Migration

  1. Card details must be collected from the client and stored securely for testing the order.
  2. According to the client and our time zone, the migration process must be executed during low-traffic hours.
  3. Notify clients about the email notification for the test order.
  4. Ask or verify all access provided by the client.

Minimum Requirements:

  • WordPress admin
  • Cpanel / Hosting Details with enabled SSH OR SSH & ftp/sftp.
  • External Database Details

Dependencies:

The destination server must be configured with the following configurations:

  • PHP minimum version 8.0 or greater.
  • MySQL version 8.0 or greater OR MariaDB version 10.5 or greater.
  • HTTPS support / SSL Certificate: Paid SSL Credentials for the destination server must be gathered and checked with the System Admin before migration.
  • memory_limit = 128M: Increase the limit to 128MB from 32 MB. If still experiencing memory errors, increase the limit to 256MB or more.
  • max_execution_time = 60: By default, PHP sets max_execution_time to 30 seconds, but increasing it to 60 seconds allows more time for scripts to complete tasks without timing out.
  • upload_max_filesize = 32M: Set to 32MB to ensure compatibility with WordPress themes and plugins.
  • post_max_size = 64M: Set to at least 64M or higher for moderate file upload needs.
  • max_input_vars = 3000: A reasonable starting point is 3000 for most WordPress sites.
  • max_input_time = 60: If data takes longer than this, PHP will terminate the process or generate an error.

Display Errors

Set display_errors = Off

Configurations to Add in wp-config.php:

  • define( ‘WP_DEBUG’, false ); // Disable WP_DEBUG mode
  • define( ‘WP_DEBUG_LOG’, true ); // Enable Debug logging to the /wp-content/debug.log file
  • define( ‘WP_DEBUG_DISPLAY’, false ); @ini_set( ‘display_errors’, 0 ); // Disable display of errors and warnings
  • define( ‘SCRIPT_DEBUG’, false ); // Disable Script Debug
  • define( ‘WP_CACHE’, false ); // Disable WordPress cache
  • Check the Server Cache mechanism

Multisite Network:

  • The below configuration must be enabled on the server if you are migrating a multi-site network:

define( 'WP_ALLOW_MULTISITE', true );
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
  • If the multisite network is being built using subdomains, the destination servers must have configured the same subdomains.

File Permissions:

  • Directory Permissions:
    • WordPress Directories: 755
      • wp-includes, wp-admin, wp-content, wp-content/themes, wp-content/plugins, wp-content/uploads, wp-admin/js
    • Uploads Directory (wp-content/uploads): 755
  • File Permissions:
    • WordPress Files: 644
    • wp-config.php: 600
    • .htaccess: 600

Database Access Rules:

  • Must not use web-based tools like Adminer, db.php, etc. Use SQLYog OR SSH Terminus.
  • Database collation must be checked using tools > site health > info > Database > Database collation. Recommended collation: utf8mb4_unicode_ci or utf8mb4_unicode_520_ci.
  • A staging environment must be kept unless explicitly requested by the client to remove it.

Advisable Database Migration:

  • If the website stores dynamic data like orders, bookings, account details, form submissions, etc., don’t migrate the database directly.
  • In such cases, let the client know about extra hours needed, and after approval, serve it as a separate task.

Backup:

  • Permission Checking
  • Add a backup process link

Migration Approach:

  • Tool Approach
      1. Server Tool: Within the same server most servers offer user-friendly and comprehensive tools and methods for site migration. If free, It’s crucial to thoroughly review the documentation provided for the tool or process.
        1. For an ex: Nexcess or WP Engine Inbuilt migration feature
  • Plugin Approach
    1. UpdraftPlus: Instead of downloading and uploading files to another server, explore direct data synchronization of the updraft.
    2. In the case of multi-site migration, we will need premium extensions like Updraft Network / Multisite Addon.
      1. Backup: Taking backup using UpdraftPlus is super easy.
        1. Configure UpdraftPlus backup settings using /wp-admin/options-general.php?page=updraftplus as below
        2. Go to Settings > Updraftplus backup > Backup / Restore > Backup Now
      2. Go to Migrate / Clone
        1. Send the backup to another site
          1. Add site.
          2. Add site key: Keys for a site are created in the section that receives a backup from a remote site. So, get the key from the remote site.
          3. Send & Wait till the process is completed.
          4. Go to Settings > Updraftplus backup > restore appropriate set of backups.
        2. Download the required backup from Existing ones after the download process is completed.
          1. Go to Settings > Updraftplus backup > Backup / Restore on the destination site.
          2. Use the option to upload backup files & once the upload process completes.
          3. Restore the appropriate setup.
        3. GPL Plugin: http://siteproofs.com/projects/zealousweb/premium-plugins/updraftplus.zip
        4. Licensing terms: https://updraftplus.com/faqs/what-licence-does-updraftplus-use/
  • SSH / Manual
    • Backup Website: Use the below standardized conventions to store backups
      • Directory Name: cust-backups
        1. Directory: wp-content/cust-backups
        2. Add the following code to index.php in the same directory
<?php 
// Silence is golden
  • Files:
      1. files-bkp-site_name-dd-mm-YYYY-H:i.zip
        Ex: files-bkp-zealousweb-10-06-2024-11:00.zip
  • Database:
    1. db-bkp-site_name-dd-mm-YYYY-H:i.gz

Ex:db-bkp-zealousweb-10-06-2024-11:00.sql.gz

  • Create Backup Folder:
      1. cd path_of_wordpress_content_directory
      2. mkdir cust-backup
    1. Create Files Backup: Backup your files using the below SSH Commands.
      1. cd path_of_wordpress_installation_directory
      2. zip -r files-bkp-zealousweb-10-06-2024-11:00.zip . -x “wp-content/cust-backups/*” “wp-content/updraft/*” “files-bkp-zealousweb-10-06-2024-11:00.zip”
      3. mv files-bkp-zealousweb-10-06-2024-11:00.zip wp-content/cust-backup/
    2. Create Database Backup: Backup your website database through the below SSH Commands.
      1. cd path_of_cust_backup_directory
      2. mysqldump -u database_username -p database_name | gzip > db-bkp-zealousweb-10-06-2024-11:00.sql.gz
      3. Enter Password: *************
    3. Sync Files: Verifying SSH commands*
    4. Download & Upload: Verifying SSH Commands*
    5. Create a New Database in the Destination Server:
      1. mysql -u root -p
      2. Enter password: ****
      3. CREATE DATABASE IF NOT EXISTS db_name;
      4. Exit;
  • Manual:
      1. Add PHP script for unzip the zip file via FTP
      2. MIgrate zip from one server to another
  • Import Database:
      1. cd path_of_cust_backup_directory
  • Convert .gz to .sql format:
        1. gzip -d db-bkp-zealousweb-10-06-2024-11:00.sql.gz
  • Import SQL Database:
        1. mysql -u username -p database_name < db-bkp-zealousweb-10-06-2024-11:00.sql
          1. mysql: MySQL command-line client.
          2. -u username: Specifies the MySQL username that will be used to connect to the MySQL server.
          3. -p: MySQL to prompt for the password of the MySQL user specified with the -u option.
          4. database_name: Name of the MySQL database where you want to import the SQL file.
          5. -db-bkp-zealousweb-10-06-2024-11:00.sql: It tells MySQL to take the contents of the db-bkp-zealousweb-10-06-2024-11:00.sql and use it as input for the mysql command.
      1. Search and Replace URLs: Search and replace using SSH or manually search and replace all instances of your old website URL in the database.
        1. mysql -u root -p
        2. Enter Password: ******
        3. USE your_database_name;
        4. Single site –
          1. UPDATE wp_options SET option_value = replace(option_value, ‘oldurl.com’, ‘newurl.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
          2. UPDATE wp_posts SET guid = replace(guid, ‘oldurl.com’,’newurl.com’);
          3. UPDATE wp_posts SET post_content = replace(post_content, ‘oldurl.com’, ‘newurl.com’);
          4. UPDATE wp_postmeta SET meta_value = replace(meta_value,’oldurl.com’,’newurl.com’);
          5. Exit;
  • Multisite: In Progress*
  • Extract Files:
      1. cd path_of_cust_backup_directory
      2. mv files-bkp-zealousweb-10-06-2024-11:00.zip path_of_wordpress_installation_directory
      3. cd path_of_wordpress_installation_directory
      4. unzip files-bkp-zealousweb-10-06-2024-11:00.zip
      5. Update wp-config.php: Update the wp-config.php file on your new server with the database credentials with the new database.
define( 'DB_NAME', 'db_name' );
define( 'DB_USER', 'db_username’ );
define( 'DB_PASSWORD', 'db_password' );
  1. Update DNS Settings: If you are migrating to a new domain or changing the domain name, update the DNS settings to point to the IP address of your new server.
  2. Update Permalinks and Settings: Log in to the WordPress admin dashboard on your new server and update permalinks and any other settings as necessary.
  3. Remove Old Files: After confirming that the migration was successful, you can delete the files from your old server to free up space.

Checklist SOP Site Migration

General Notes Checklist

  1. Set the staging site to no-index; set the live site to allow indexing.
  2. Enable maintenance mode on staging and production sites.
  3. Retain the latest three backups (excluding server tools).

Pre-Migration Checklist (High to Low Priority)

  1. Client Coordination
    • Secure client card details for test orders.
    • Schedule migration during low-traffic hours per client’s timezone.
    • Notify the client of the test order email.
  2. Access Verification
    • Verify access: WordPress admin, CPanel/SSH, FTP/SFTP, database.
  3. Server Requirements
    • PHP 8.0+, MySQL 8.0+/MariaDB 10.5+, SSL credentials.
    • Server configs: memory_limit 128M, max_execution_time 60, upload_max_filesize 32M, post_max_size 64M, max_input_vars 3000, max_input_time 60, display_errors Off.
  4. WordPress Configurations
    • Update wp-config.php:
      • Disable WP_DEBUG.
      • Enable WP_DEBUG_LOG.
      • Disable WP_DEBUG_DISPLAY and SCRIPT_DEBUG.
      • Set WP_CACHE to false.
    • Check the server cache mechanism.
  5. Multisite Network Setup (if applicable)
    • Enable WP_ALLOW_MULTISITE, set memory_limit to 256M, upload_max_filesize and post_max_size to 64M.
    • If using subdomains, ensure the destination server is configured with the same subdomains.
  6. File Permissions
    • Set directories to 755, files to 644, wp-config.php, and .htaccess to 600.
  7. Database Setup
    • Avoid web-based tools (use SQLYog or SSH).
    • Verify database collation: utf8mb4_unicode_ci or utf8mb4_unicode_520_ci.
    • For dynamic data sites, notify the client for additional time if database migration is complex.
  8. Backup
    • Take a destination backup before migration and add a backup process link.

Migration Approach Checklist

Tool-Based Migration

  • Server Tool (Preferred)
    1. Use available server migration tools (e.g., Nexcess, WP Engine).
    2. Review tool documentation thoroughly.
  • UpdraftPlus Plugin
    1. Single Site: Use UpdraftPlus for direct sync.
    2. Multisite: Use UpdraftPlus Network/Multisite Addon.
    3. Configure settings, obtain the site key, initiate the transfer, and restore the backup.

SSH/Manual Migration

  • Backup Creation
    1. Create cust-backups in wp-content.
    2. Backup files: files-bkp-site_name-dd-mm-YYYY-H:i.zip.
    3. Backup database: db-bkp-site_name-dd-mm-YYYY-H:i.gz.
  • Manual Migration
    1. Create a new database on the destination.
    2. Transfer and unzip files; import SQL database.
    3. Search and replace old URLs in the database.

Post-Migration

  1. File Extraction & Configuration
    • Extract files in the WordPress directory.
    • Update wp-config.php with new database credentials.
  2. Final Adjustments
    • Update DNS if the domain changes.
    • Refresh permalinks; delete old server files after validation.

Post-Migration QA Checklist

  1. Functionality Testing
    • Test all contact forms, lead generation, and e-commerce features with dummy data.
  2. Site Comparison
    • Compare migrated site with old/staging site; address discrepancies promptly.
  3. QA Review
    • Conduct a comprehensive QA review by the designated team.
  4. Stakeholder Notification
    • Inform client, team lead, and project manager upon QA completion.