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
- Discourage search engines to index the staging site and encourage them to index the live website.
- Maintenance mode must be active on both the staging and production sites.
- In any backup method, we must retain up to only three latest backups, except server tools.
Pre Migration
- Card details must be collected from the client and stored securely for testing the order.
- According to the client and our time zone, the migration process must be executed during low-traffic hours.
- Notify clients about the email notification for the test order.
- 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
- WordPress Directories: 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
-
- 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.
- For an ex: Nexcess or WP Engine Inbuilt migration feature
- 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.
-
- Plugin Approach
-
- UpdraftPlus: Instead of downloading and uploading files to another server, explore direct data synchronization of the updraft.
- In the case of multi-site migration, we will need premium extensions like Updraft Network / Multisite Addon.
- Backup: Taking backup using UpdraftPlus is super easy.
- Configure UpdraftPlus backup settings using /wp-admin/options-general.php?page=updraftplus as below
- Go to Settings > Updraftplus backup > Backup / Restore > Backup Now
- Go to Migrate / Clone
- Send the backup to another site
- Add site.
- 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.
- Send & Wait till the process is completed.
- Go to Settings > Updraftplus backup > restore appropriate set of backups.
- Download the required backup from Existing ones after the download process is completed.
- Go to Settings > Updraftplus backup > Backup / Restore on the destination site.
- Use the option to upload backup files & once the upload process completes.
- Restore the appropriate setup.
- GPL Plugin: http://siteproofs.com/projects/zealousweb/premium-plugins/updraftplus.zip
- Licensing terms: https://updraftplus.com/faqs/what-licence-does-updraftplus-use/
- Send the backup to another site
- Backup: Taking backup using UpdraftPlus is super easy.
- SSH / Manual
-
- Backup Website: Use the below standardized conventions to store backups
- Directory Name: cust-backups
- Directory: wp-content/cust-backups
- Add the following code to index.php in the same directory
- Directory Name: cust-backups
- Backup Website: Use the below standardized conventions to store backups
<?php
// Silence is golden
- Files:
-
-
- files-bkp-site_name-dd-mm-YYYY-H:i.zip
Ex: files-bkp-zealousweb-10-06-2024-11:00.zip
- files-bkp-site_name-dd-mm-YYYY-H:i.zip
-
- Database:
-
- db-bkp-site_name-dd-mm-YYYY-H:i.gz
Ex:db-bkp-zealousweb-10-06-2024-11:00.sql.gz
- Create Backup Folder:
-
-
- cd path_of_wordpress_content_directory
- mkdir cust-backup
- Create Files Backup: Backup your files using the below SSH Commands.
- cd path_of_wordpress_installation_directory
- 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”
- mv files-bkp-zealousweb-10-06-2024-11:00.zip wp-content/cust-backup/
- Create Database Backup: Backup your website database through the below SSH Commands.
- cd path_of_cust_backup_directory
- mysqldump -u database_username -p database_name | gzip > db-bkp-zealousweb-10-06-2024-11:00.sql.gz
- Enter Password: *************
- Sync Files: Verifying SSH commands*
- Download & Upload: Verifying SSH Commands*
- Create a New Database in the Destination Server:
- mysql -u root -p
- Enter password: ****
- CREATE DATABASE IF NOT EXISTS db_name;
- Exit;
-
- Manual:
-
-
- Add PHP script for unzip the zip file via FTP
- MIgrate zip from one server to another
-
- Import Database:
-
-
- cd path_of_cust_backup_directory
-
- Convert .gz to .sql format:
-
-
-
- gzip -d db-bkp-zealousweb-10-06-2024-11:00.sql.gz
-
-
- Import SQL Database:
-
-
-
- mysql -u username -p database_name < db-bkp-zealousweb-10-06-2024-11:00.sql
- mysql: MySQL command-line client.
- -u username: Specifies the MySQL username that will be used to connect to the MySQL server.
- -p: MySQL to prompt for the password of the MySQL user specified with the -u option.
- database_name: Name of the MySQL database where you want to import the SQL file.
- -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.
- mysql -u username -p database_name < db-bkp-zealousweb-10-06-2024-11:00.sql
- Search and Replace URLs: Search and replace using SSH or manually search and replace all instances of your old website URL in the database.
- mysql -u root -p
- Enter Password: ******
- USE your_database_name;
- Single site –
- UPDATE wp_options SET option_value = replace(option_value, ‘oldurl.com’, ‘newurl.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
- UPDATE wp_posts SET guid = replace(guid, ‘oldurl.com’,’newurl.com’);
- UPDATE wp_posts SET post_content = replace(post_content, ‘oldurl.com’, ‘newurl.com’);
- UPDATE wp_postmeta SET meta_value = replace(meta_value,’oldurl.com’,’newurl.com’);
- Exit;
-
-
- Multisite: In Progress*
- Extract Files:
-
-
- cd path_of_cust_backup_directory
- mv files-bkp-zealousweb-10-06-2024-11:00.zip path_of_wordpress_installation_directory
- cd path_of_wordpress_installation_directory
- unzip files-bkp-zealousweb-10-06-2024-11:00.zip
- 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' );
- 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.
- Update Permalinks and Settings: Log in to the WordPress admin dashboard on your new server and update permalinks and any other settings as necessary.
- 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
- Set the staging site to no-index; set the live site to allow indexing.
- Enable maintenance mode on staging and production sites.
- Retain the latest three backups (excluding server tools).
Pre-Migration Checklist (High to Low Priority)
- 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.
- Access Verification
- Verify access: WordPress admin, CPanel/SSH, FTP/SFTP, database.
- 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.
- 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.
- Update wp-config.php:
- 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.
- File Permissions
- Set directories to 755, files to 644, wp-config.php, and .htaccess to 600.
- 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.
- Backup
- Take a destination backup before migration and add a backup process link.
Migration Approach Checklist
Tool-Based Migration
- Server Tool (Preferred)
- Use available server migration tools (e.g., Nexcess, WP Engine).
- Review tool documentation thoroughly.
- UpdraftPlus Plugin
- Single Site: Use UpdraftPlus for direct sync.
- Multisite: Use UpdraftPlus Network/Multisite Addon.
- Configure settings, obtain the site key, initiate the transfer, and restore the backup.
SSH/Manual Migration
- Backup Creation
- Create cust-backups in wp-content.
- Backup files: files-bkp-site_name-dd-mm-YYYY-H:i.zip.
- Backup database: db-bkp-site_name-dd-mm-YYYY-H:i.gz.
- Manual Migration
- Create a new database on the destination.
- Transfer and unzip files; import SQL database.
- Search and replace old URLs in the database.
Post-Migration
- File Extraction & Configuration
- Extract files in the WordPress directory.
- Update wp-config.php with new database credentials.
- Final Adjustments
- Update DNS if the domain changes.
- Refresh permalinks; delete old server files after validation.
Post-Migration QA Checklist
- Functionality Testing
- Test all contact forms, lead generation, and e-commerce features with dummy data.
- Site Comparison
- Compare migrated site with old/staging site; address discrepancies promptly.
- QA Review
- Conduct a comprehensive QA review by the designated team.
- Stakeholder Notification
- Inform client, team lead, and project manager upon QA completion.