Syntax
mwp [flag] <push|pull|rollback|report> <sitename>Without the alias, that is bash migratewp.sh [flag] <action> <sitename>. Run mwp with no arguments, or with an action it does not recognise, and it prints the usage message.
Push
Migrates a site from your local machine to the remote server.
$ mwp push mysiteWhat happens, in order:
- Pre-flight checks. Local site running, local directory present, WP-CLI available, SSH login working, remote directory present.
- Backup. The remote
wp-contentis copied towp-content_bakon the server, and the remote database is dumped. - Sync. rsync copies the changed files from your Mac to the server.
- Database. The local database is exported, moved across, imported, and WP-CLI runs a search and replace from
localURLtoremoteURL. - Log. The migration is written to the site's changelog against your
logUserName.
Pull
Migrates a site from the remote server to your local machine.
$ mwp pull mysiteThe same sequence in reverse: your local wp-content is backed up to wp-content_bak and your local database is exported to db_bak.sql before anything is overwritten, then the remote files and database come down and the URL is replaced with localURL.
Pull overwrites your local site. That is the point of it — but if you have local work in wp-content that is not committed anywhere, it lives only in wp-content_bak after a pull.
Rollback
Undoes a migration, restoring from the backup taken when it ran.
$ mwp rollback mysiteMigrateWP asks which migration you want to roll back to before it does anything, then restores the files from wp-content_bak and reimports the database dump. The rollback is itself recorded in the changelog, so the history stays honest.
Report
Prints the migration history for a site.
$ mwp report mysiteThe changelog (mwp.log) is kept alongside wp-content on the remote server, so every developer's pushes and pulls land in the same file. report fetches it over SSH and prints it. If a site has never been migrated, it reports that no report is available.
Flags
| Flag | Meaning |
|---|---|
-f |
Full run — take backups, then migrate. This is also what happens when you pass no flag at all, so mwp push mysite and mwp -f push mysite do the same thing. |
-d |
Dry run. Reserved for the rsync dry run that reports what a migration would change. Not yet enabled — see the roadmap. |
-h, -? |
Print the usage message and exit. |
$ mwp -h
Usage: bash migratewp.sh -d [<pull|push|rollback|report>] [Sitename]What gets left behind
| File | Where | What it is |
|---|---|---|
wp-content_bak | Beside wp-content, on whichever side was overwritten | The file backup rollback restores from. |
db_bak.sql | Local WordPress root, after a pull | The database backup rollback restores from. |
mwp.log | Beside wp-content on the remote server | The shared changelog report reads. |