WordPress site migration and deployment using wp-migrate.sh...
This skill provides expertise for working with the wp-migrate.sh WordPress migration tool.
wp-migrate.sh is a comprehensive WordPress migration tool that operates in two modes:
Current Version: Check the latest release
git describe --tags --abbrev=0 # Get current version from git
Latest Release: See GitHub Releases
Repository: BWBama85/wp-migrate.sh
Main Branch: main
Push Mode:
./wp-migrate.sh --dest-host user@dest.example.com --dest-root /var/www/site
Archive Mode:
./wp-migrate.sh --archive /path/to/backup.zip
./wp-migrate.sh --archive /path/to/backup.tar.gz --archive-type jetpack
Dry Run:
./wp-migrate.sh --dest-host user@dest --dest-root /var/www/site --dry-run --verbose
Rollback (v2.6.0):
./wp-migrate.sh --rollback # Auto-detects latest backups
./wp-migrate.sh --rollback --rollback-backup /path/to/specific/backup # Specific backup
./wp-migrate.sh --rollback --yes # Skip confirmation for automation
Automation-Friendly (v2.6.0):
./wp-migrate.sh --archive /path/to/backup.zip --yes --quiet # CI/CD: skip prompts, no progress bars
Run all tests:
make test
Run specific test:
./test-wp-migrate.sh
ShellCheck validation:
shellcheck wp-migrate.sh
The project uses a modular source structure:
src/
āāā header.sh # Shebang, defaults, variable declarations
āāā lib/
ā āāā core.sh # Core utilities (log, err, validate_url)
ā āāā functions.sh # All other functions
ā āāā adapters/ # Archive format adapters
ā āāā README.md
ā āāā duplicator.sh
ā āāā jetpack.sh
ā āāā solidbackups.sh
āāā main.sh # Argument parsing and main execution
IMPORTANT: Modifications should be made in src/ files, NOT in wp-migrate.sh directly.
After modifying source files:
make build
This will:
A pre-commit hook prevents committing source changes without rebuilding:
ln -s ../../.githooks/pre-commit .git/hooks/pre-commit
Branching: Create from main using descriptive names:
feature/<slug> for enhancementsfix/<slug> for bug fixesdocs/<slug> for documentationchore/<slug> for maintenanceCommits: Use .gitmessage template format:
type: short imperative summary
Longer explanation if needed
Types: feat, fix, docs, chore, refactor, test
Changelog: Update CHANGELOG.md under [Unreleased] section with every feature or fix
Pull Requests:
Merging: Keep main release-ready with git merge --no-ff or squash after review
Releases: Tag with semantic versioning (e.g., git tag v2.7.0)
When creating PRs, ensure:
git log main..HEAD and git diff main...HEAD)Permission Errors on Managed Hosts (StellarSites)
--stellarsites flag to exclude protected mu-pluginsstellarsites-cloud)Database Import Fails
URL Search-Replace Issues
--verbose to see detected URLs--dest-home-url or --dest-site-url if detection fails--no-search-replace for faster migrations that only need home/siteurl updatedArchive Detection Fails
--archive-type to specify format (duplicator, jetpack, solidbackups)Non-Interactive Context Failures (v2.6.0)
--yes flag when running in CI/CD, cron, or pipeline contextsRollback Issues (v2.6.0)
--rollback-backup /path/to/backup to specify explicitlySSH Connection Issues
--ssh-opt (can be repeated)--ssh-opt 'Port=2222' or --ssh-opt 'ProxyJump=bastion'ShellCheck Errors
brew install shellcheck (macOS) or see https://www.shellcheck.net/shellcheck wp-migrate.shShow verbose migration preview:
./wp-migrate.sh --dest-host user@dest --dest-root /var/www/site --dry-run --verbose
Show every command (trace mode):
./wp-migrate.sh --dest-host user@dest --dest-root /var/www/site --dry-run --trace
Check archive structure:
unzip -l /path/to/backup.zip | head -50
tar -tzf /path/to/backup.tar.gz | head -50
Verify wp-cli on destination:
ssh user@dest 'cd /var/www/site && wp core version'
The script uses an extensible adapter system for different backup formats.
dup-installer/dup-database__*.sql structuresql/*.sql multi-file structurewp-content/uploads/backupbuddy_temp/{ID}/See src/lib/adapters/README.md for contributor guide.
Each adapter must implement:
validate_<adapter>() - Check if file matches formatextract_<adapter>() - Extract archive to temp directorydetect_db_<adapter>() - Find database file(s)detect_wp_content_<adapter>() - Find wp-content directorymake build after any source changes to regenerate wp-migrate.shUse Grep tool for code searches:
pattern: "function_name"
output_mode: "content"
-n: true (show line numbers)
Use Read tool for file contents:
file_path: /Volumes/personal/codeprojects/bash/wp-migrate/src/lib/functions.sh
Use Edit tool for precise changes:
file_path: /Volumes/personal/codeprojects/bash/wp-migrate/src/lib/functions.sh
old_string: "exact match from file"
new_string: "replacement text"
git status
git diff main...HEAD # See all changes in branch
git log main..HEAD # See all commits in branch
make build after source changes