Command reference

Four commands and three flags. Each command takes the site name you set in migratewp.conf.

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 mysite

What happens, in order:

  1. Pre-flight checks. Local site running, local directory present, WP-CLI available, SSH login working, remote directory present.
  2. Backup. The remote wp-content is copied to wp-content_bak on the server, and the remote database is dumped.
  3. Sync. rsync copies the changed files from your Mac to the server.
  4. Database. The local database is exported, moved across, imported, and WP-CLI runs a search and replace from localURL to remoteURL.
  5. 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 mysite

The 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 mysite

MigrateWP 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 mysite

The 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

FlagMeaning
-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

FileWhereWhat it is
wp-content_bakBeside wp-content, on whichever side was overwrittenThe file backup rollback restores from.
db_bak.sqlLocal WordPress root, after a pullThe database backup rollback restores from.
mwp.logBeside wp-content on the remote serverThe shared changelog report reads.