CLI tool for migrating WordPress multisite databases between Wake Forest University environments
npm install wfu-migrateA CLI tool for migrating WordPress multisite databases between Wake Forest University environments (dev, uat, pprd, prod, local).
- Serialization-safe migrations: Uses WP-CLI via Docker for all search-replace operations, ensuring serialized PHP data is preserved correctly
- Single-site migration: Migrate individual sites between any environment
- Environment migration: Refresh entire lower environments from production
- S3 integration: Automatic file sync and backup archival
- Resume capability: Continue interrupted migrations from where they left off
- Pre-flight checks: Validates prerequisites before migration
- Node.js 18+ LTS
- Docker Desktop (for WP-CLI operations)
- AWS CLI (for S3 operations)
- Access to WFU database endpoints
``bash`
npm install -g wfu-migrate
Or for development:
`bash`
git clone
cd wfu-migrate
./init.sh
1. Configure the tool:
`bash`
wfu-migrate config wizard
2. Check system readiness:
`bash`
wfu-migrate doctor
3. Migrate a single site:
`bash`
wfu-migrate migrate 123 --from prod --to dev
4. Migrate entire environment:
`bash`
wfu-migrate env-migrate dev
Migrate a single site between environments.
`bash`
wfu-migrate migrate
Options:
- --from - Source environment (dev, uat, pprd, prod) [required]--to
- - Target environment (dev, uat, pprd, prod, local) [required]--dry-run
- - Preview changes without executing-f, --force
- - Skip confirmation prompts-v, --verbose
- - Show detailed output--homepage
- - Include homepage (site ID 1) tables--custom-domain
- - Custom domain replacement--skip-backup
- - Skip target backup (dangerous)--skip-s3
- - Skip S3 sync and archival--work-dir
- - Custom working directory--keep-files
- - Keep local SQL files after completion--timeout
- - Timeout for database operations (default: 20)
Migrate full environment from production to lower environment.
`bash`
wfu-migrate env-migrate
Target: uat, dev, or local (source is always prod)
Options:
- --dry-run - Preview changes without executing-f, --force
- - Skip confirmation prompts-v, --verbose
- - Show detailed output--network-only
- - Migrate network tables only--sites-only
- - Migrate sites only (skip network tables)--batch-size
- - Sites per batch (default: 5)--parallel
- - Process sites in parallel--concurrency
- - Max concurrent migrations (default: 3)--include-sites
- - Comma-separated site IDs to include--exclude-sites
- - Comma-separated site IDs to exclude--active-only
- - Only migrate active sites--exclude-main-site
- - Exclude site ID 1--skip-backup
- - Skip environment backup--skip-s3
- - Skip S3 archival and sync--auto-rollback
- - Automatically rollback on failure--max-retries
- - Retries for failed operations (default: 3)--health-check
- - Pre/post migration health checks--resume
- - Resume incomplete migration--list-migrations
- - List incomplete migrations--skip-failed
- - Skip previously failed sites when resuming--retry-failed
- - Retry only failed sites when resuming
Configuration management.
`bash`
wfu-migrate config wizard # Interactive setup
wfu-migrate config set
wfu-migrate config get
wfu-migrate config list # List all (passwords masked)
wfu-migrate config verify # Verify configuration
wfu-migrate config reset # Reset to defaults
wfu-migrate config import_wfuwp # Import from wfuwp
System diagnostics and health checks.
`bash`
wfu-migrate doctor
Checks:
- Docker availability
- MySQL client (native or Docker fallback)
- AWS CLI configuration
- Configuration validity
- Environment connectivity
- Migration database readiness
- S3 bucket accessibility
The tool handles complex URL patterns for WFU's asymmetric environment structure:
Configuration is stored at ~/.wfu-migrate/config.json. Passwords are encrypted using AES-256-CBC.
WordPress databases contain serialized PHP data with string length prefixes:
`php`
s:15:"example.wfu.edu"
Simple SQL REPLACE() operations break this serialization by changing the string without updating the length prefix. WP-CLI correctly:
1. Unserializes the data
2. Performs replacements
3. Re-serializes with correct length prefixes
`bashInstall dependencies
npm install
MIT