{ "name": "MU Migration", "slug": "mu-migration", "version": "0.7.0", "download_url": "https://gitea.mulligan.casa/wordpress/wp-updates/raw/branch/main/mu-migration/mu-migration-0.7.0.zip", "homepage": "https://gitea.mulligan.casa/wordpress/mu-migration", "requires": "6.1", "tested": "7.0", "requires_php": "8.1", "last_updated": "2026-10-09 13:31:01", "author": "Mike Mulligan", "author_homepage": "https://gitea.mulligan.casa/mmulligan", "tags": [ "multisite", "migration", "wp-cli", "export", "import" ], "sections": { "description": "
MU Migration adds a wp mu-migration command family to WP-CLI. It exports a site's tables, users, and optionally its plugins, themes and uploads into one zip package, then imports that package into a multisite network as a new or existing subsite, or into a single site. On import it rewrites the table prefix, remaps user ids into the network's shared users table, rewrites the site's address and uploads path in its tables, and performs the housekeeping a moved site needs.
This is a maintained fork of MU-Migration, created by Nícholas André at 10up and archived on 2 March 2026. The fork runs on current PHP, ships as an ordinary plugin with self-hosted updates, and plans every run before it does anything.
\nCommands
\nwp mu-migration export all <zip> exports tables, users and meta data, plus --plugins, --themes and --uploads when asked. The <zip> is required.wp mu-migration export tables <file> and export users <file> export one piece at a time; the <file> is required.--blog-id, or without it the site WP-CLI runs against (--url, or the main site).wp mu-migration import all <zip> imports a package: into a new subsite at --new-url (or the package's own address with --same-url), or over an existing site with --blog-id. --uid-fields and --uid-columns name the post-meta keys and the plugin table columns that hold user ids. --upload-collisions=keep or --upload-collisions=replace says what to do with a package upload already on the site with other content, which otherwise refuses the import. --installed-versions=keep or --installed-versions=replace says what to do with a requested plugin or theme installed at another version than the package's copy, which otherwise refuses it too. Each replace needs --backup-dir, and replacing a plugin or theme another site of the network runs needs --dangerously-allow-shared-code-replace.wp mu-migration import tables <file> --blog-id=<id> and import users <file> --blog-id=<id> --map-file=<map> import one piece at a time; --map-file is required and names where the old-id to new-id map is written.wp mu-migration posts update_author <map> --blog-id=<id> remaps post authors, comment authors, link owners (links.link_owner), each post's last editor (_edit_last), --uid-fields post meta and the --uid-columns columns (--uid-columns=em_events.event_owner) to the new user ids. import all remaps the same.wp mu-migration users update_passwords sets or resets passwords after a move.wp mu-migration info prints the tool's version.Plan, refuse, confirm, apply
\nEvery command first builds a plan by running its real logic against recording executors: reads are real, and every write becomes a plan step with its exact arguments. The dump is copied, rewritten and scanned inside a private work directory, and every check of the URL rewrite that needs no imported row is made, so a rewrite that cannot run is refused before anything is written. The plan is printed before anything is applied.
\n--dry-run stops there and closes with Dry run: N steps planned; this tool wrote nothing outside its private work directory, which is removed when this run ends. This tool starts no process that loads the target site's code, unserializes nothing, and counts nothing the URL rewrite would change, since those rows are the import's. The site's own code can still write: WP-CLI itself has already loaded the site it runs against (--url, or the main site) with its theme and plugins, network-active plugins included. Before a dry run on a site whose code writes when it loads, back up its tables or rehearse on a copy.Continue?. --yes skips the question and acknowledges nothing.--quiet, or when standard input is not an interactive terminal. A live --format=json run needs --yes.Acknowledgement flags
\n--allow-main-site: any write to the network's main site (or the only site of a single-site install), and every network-wide plugin activation.--dangerously-allow-drop-tables: a dump that drops a table that exists now.--dangerously-allow-table-changes: a dump that changes an existing table in place (REPLACE, ALTER, or INSERT without recreating it).--dangerously-allow-global-tables: widening the URL rewrite to whichever of the network's users, usermeta, blogs, site and sitemeta tables exist.--allow-overwrite: writing an output file over an existing one.--dangerously-allow-role-overwrite: replacing the role of an existing user who already has one on the target site.--allow-password-reset-mail: mailing password-reset links, the tool's only outbound network call.--dangerously-allow-nested-url: a URL change whose new address is the old one plus a path (https://net.test to https://net.test/site3), which also rewrites every other address under the old one, links to sibling sites included.--dangerously-allow-shared-code-replace: --installed-versions=replace of a plugin or theme another site of the network runs (active there, network-active, or the parent of its theme). The new code runs on those sites too, and the run's undo cannot put them back; the refusal names them.Two more flags request behaviour that is off by default, and the confirmation lists them: --dangerously-allow-guid-rewrite (the URL rewrite otherwise always skips the guid column) and --dangerously-allow-database-redirects (dumps with USE, database-qualified names or a REFERENCES into another database are otherwise refused; allowing them prints a DANGER warning even under --quiet, because such statements can write outside the backed-up database).
Every flag is bare: a value or a --no- negation is refused. Former spellings, such as --blog_id or --allow-drop-tables, are refused with the name that replaced them.
Safety behaviour
\n<backup-dir>/mu-migration-backup-blog<id>-<timestamp>.sql, an owner-only (0600) file in an owner-only (0700) directory. --backup-dir must be absolute and outside the WordPress root. This backup does not cover network tables, users and memberships, uploads, plugin and theme directories or redirected databases: take a full backup first.wp db import - on standard input, where the database client stops at the first statement that fails. The import fails, naming the error and its line, when the client exits non-zero or prints an ERROR line. wp db import <file> carries on past a failed statement and exits 0.IF NOT EXISTS and never drops, and a table it writes with INSERT DELAYED (whose rows the server queues), are named in the plan as not counted.C: payload that is not serialized data, a value that does not parse, a row another writer changed during the run and a value that would duplicate a unique key or not fit its column are left as they were and counted; a table with no usable key, a column the connection's charset cannot carry, a generated column and user_pass are skipped and named. What needs no imported row is refused while the plan is built, before anything is written: disagreeing connection charsets, a row whose rewrite would not fit max_allowed_packet (the new values travel as hexadecimal, so from about half the packet, less for a longer new address or a dump in another charset; the plan prints the bound), or a finite memory_limit it would exceed. Under WP-CLI's memory_limit of -1 the step runs bounded, and a PHP fatal error during any step still prints the step and its recovery block. Each changed row is written only if it still holds what was read, in batches of one transaction each, and only in the database session that began the batch: a read/write-splitting proxy is not supported (it fails the step after the import, nothing of that batch written), so point WP-CLI at the primary. Triggers and ON UPDATE timestamps fire, and with binary logging on every changed row is logged (in row format whole, before and after), so check the servers' disk space before a large import. The closing lines and the JSON run record (url_rewrites) say what was changed, what was left and why, and what was not rewritten; rows another writer changed are also a warning, printed under --quiet too. A run that fails after the rewrite, a PHP fatal error included, prints that report before its error.guid unless asked. The URL is matched only as a whole host and path, the host in any case. --new-url and --old-url must start with http:// or https:// and a valid host, and may not hold %. The new URL's scheme is written into every http:// and https:// reference, plain, JSON-escaped or URL-encoded. Each reference is moved in its own form, the whole address (host, port and path) written in it; protocol-relative and bare references keep their form. An e-mail address at the old host is never rewritten, and a bare single-label host such as localhost is left alone. The uploads path moves in every form, and only in the site's own references. A read-only scan afterwards reports, per column, the values that still hold the old host.meta.json values, dump names, logins) is printed with its control characters as escapes.users.json (format 3), which carries every role a user holds on the exported site, every usermeta row that travels, byte for byte, and from a network each account's spam and deleted flags. Session tokens and application passwords never travel; the per-site keys WordPress itself writes are moved to the target site's prefix, and every other key keeps its name. A users file of format 2 (0.5.x) or a users.csv from a version before 0.5.0 is refused: re-export it. A new user's user_status, and on a network its flags, are written with its password hash, so an account flagged on the source network arrives flagged; on a single site, which cannot record the flags, an account the import would create flagged is refused by name. When another account holds a new user's nicename, the plan says which numbered nicename WordPress will store and that their author archive moves.added_user_meta or updated_user_meta hook fires for them; the plugin's own user-data hooks still run. A value the database column cannot hold stops the run, naming the user, the key and the row; on a usermeta table that keeps no transactions (MyISAM), it also names the rows already written.--role-definitions=destination keeps the site's own definitions instead. The plan, the closing lines and the JSON run record (role_definitions) list, per role, the capabilities the merge adds and removes.--plugins and --themes. A plugin is activated as WordPress activates it: on a network, one whose header says Network: true is activated network-wide, so it needs --allow-main-site; on a single site every activation is the site's own. Every activation comes after the URL rewrite and, when the address changes, the scan that follows it, so an activation hook sees the site at its new address. One already active once the dump has run is left alone. One already installed is compared with the package's copy by its Version header: the same version is left alone, and another, or one that cannot be read, refuses the import, naming both versions, unless --installed-versions=keep keeps the installed code or --installed-versions=replace moves it into --backup-dir and installs the package's. Plugin and theme code is shared by every site of a network: replacing code another site runs needs --dangerously-allow-shared-code-replace. The plugin and theme moves come first, before the site is created, the backup, the import and the URL rewrite. Uploads are merged: a file already there with the same content is skipped, and one with other content refuses the import unless --upload-collisions=keep keeps it or --upload-collisions=replace moves it into --backup-dir and places the package's. The undo and recovery lines put a replaced plugin, theme or upload back, remove the directories the run made for them in the backup directory, and say to reset PHP's opcode cache after a plugin or theme. A move renames only where a rename really moves the file, and otherwise copies it, keeping its mode and modification time. Uploads, plugins and themes get the modes WordPress gives them, whatever the umask.--format=json prints JSON Lines: a step record per step, a summary, a refused record when an acknowledgement is missing, and a final run record with the outcome, the backup path, the files written, the remap tallies, the upload collisions, the installed versions, the URL rewrite's counts, the URL leftovers, the peak memory and the recovery or undo lines. A step record is printed before anything is applied, so its performed is true only for what the plan build itself did; the live outcome is the run record.A run that completed prints, last, the commands that undo it: the same lines a failure would print. Recovery after a failure is printed guidance, never executed. Its restore of the backup is wp db import - < '<backup>', run from a shell, so the restore also stops at the first statement that fails. A failed filesystem step names its cause (a missing file, a directory the tool cannot write) without a PHP warning printed above it. Full usage is documented in the repository README.
wp-content/plugins/ and activate it. On multisite, network activate it so the command is available for every site.wp mu-migration info to confirm the command is registered.Requires PHP 8.1 or newer with the zip extension, WordPress 6.1 or newer, and WP-CLI with a mysql or mariadb client that can log in to the database server: the import, the backup and the export run WP-CLI's wp db commands. The MariaDB 11.8 client in the official WP-CLI Docker image cannot load caching_sha2_password, MySQL 8's default; against such a server, use a mysql_native_password database user or a MySQL client. There are no runtime Composer dependencies.
Updates are delivered through the Update URI header and the Manifest Updater plugin.
0.7.0
\ndatabase.rewrite_urls, in place of the wp search-replace children. It runs over the database alone, loads no site code and never unserializes: a serialized value is walked as text, only the strings holding the old address and their lengths are rewritten, and every object keeps its class and properties. Nothing in the plugin calls unserialize().--quiet too), a rewrite that would duplicate a unique key. Each row is written only if it still holds what was read, in batches of one transaction each.max_allowed_packet, a finite memory_limit the step would exceed, a table it cannot measure, and on MySQL a dump or backup that writes values into generated columns.run record: wp_cli_version, search_replace_unserialize_hook and search_replace_warnings are gone; it carries url_rewrites and peak_memory (PHP's real peak). A URL rewrite: closing line reports what changed, what was left and what was skipped.run record still closes the output.0.6.0
\nusers.json is format 3, and a format 2 file is refused. The users row carries spam and deleted (a network's account flags) beside user_status, each held to an integer in its column's range.user_status.Network: true is planned as WordPress activates it, network-wide, and needs --allow-main-site. Into a single site, a plugin the source ran network-active is activated on the site and stays active.import all --plugins whose dump's active_plugins row cannot be read while the plan is built is refused. A plugin the source ran network-active is activated before the search-replace children, so they no longer rewrite its serialized objects as empty ones; the plan notes that its activation hook runs while the site still has the old address.--allow-main-site.<prefix>options table the table discovery does not find is refused, naming the prefix and the server's lower_case_table_names.--uid-columns=links.link_owner is refused. links.link_owner and _edit_last are now remapped by default.sql_mode holding NO_BACKSLASH_ESCAPES, an import into an existing site found none of its tables on MySQL, so it took no backup and asked no --dangerously-allow-drop-tables. The listing now escapes with LIKE … ESCAPE '|'. The dump import also ran under that mode and read the dump as no dump tool writes it, which let a crafted row run a DROP TABLE; it now runs without NO_BACKSLASH_ESCAPES and ANSI_QUOTES.users update_passwords --role selected nobody for a role holding an _ (shop_manager) on MySQL under that mode. The URL leftover count is the same in any sql_mode and counts only what the passes left.active_plugins are read with allowed_classes false. A serialized value whose length runs past its end no longer stops the plan with a TypeError.noop into a site the run creates. An activation is judged against the site as the import leaves it, read from the dump's own active_plugins row.run record (search_replace_warnings), never as a failure.0.5.2
\nwp_404_to_301, wp_2024_archive) are exported like its others; they were left out without a word, and refused when named. Those whose number's tables include a core or network table name (wp_2_posts, wp_2_users) are another site's or install's: left out, and named in the plan.--tables and --non-default-tables may name any of them but a registered site's (a single site has none), and the plan says it was included by name; naming a registered site's table is refused in new words. posts update_author --uid-columns on such a table says so too. An import into blog 1 or a single site refuses such a table unless --tables names it, and the plan names every one a dump brings.export all --uploads from the uploads root as WordPress computes it for the network the command runs on (the main network's main site's) leaves out its sites/ folder, which holds every other site's uploads, and the plan says so. Any other site's sites/ folder, a single site's included, still travels.0.5.1
\nexport all needs its <zip>, export users its <file> and import users its --map-file; none has a default in the working directory any more, and an empty path is refused.--new-url and --old-url must start with http:// or https:// and a valid host, and may not hold %. A URL change whose new address is the old one plus a path is refused unless you pass --dangerously-allow-nested-url.--role-definitions=destination keeps the site's definitions, as before. The plan, the closing lines and the JSON run record (role_definitions) list, per role, the capabilities added and removed.import all refuses a package upload already on the site with other content, naming it, unless you pass --upload-collisions=keep or --upload-collisions=replace. One with the same content is skipped. replace moves the site's file into --backup-dir first, which it needs; the undo lines put it back. The plan and the JSON run record (upload_collisions) count them.import all with --plugins or --themes refuses a plugin or theme installed at another version than the package's copy, older or newer, naming both versions, unless you pass --installed-versions=keep or --installed-versions=replace. replace moves the installed copy into --backup-dir first, before anything else runs; the undo lines put it back and say to reset PHP's opcode cache. Replacing code another site of the network runs needs --dangerously-allow-shared-code-replace, and the refusal names those sites. The plan and the JSON run record (installed_versions) list each difference. After a replace, a live run says to reset PHP's opcode cache, in its closing lines or, under --format=json, as the run record's reset_opcode_cache./proc/self/mountinfo, a mount point inside the uploads, plugin or theme tree a move places files in, or in installed code --installed-versions=replace would move away (a single-file plugin mounted on its own included), refuses the run while the plan is built, naming the mount point, and again just before the move. A destination that is itself a mount point is fine. Where the mount table cannot be read, the plan and the run's closing lines say nested mounts were not checked, and the run goes on.FS_CHMOD_FILE and FS_CHMOD_DIR.run record carries them as undo.localhost is left alone. The uploads path moves in every form, and only in the site's own references.run record (url_leftovers).--uid-columns remaps plugin table columns of user ids. Comment authors are remapped by default, _customer_user wherever the key exists, and a user id of 0 means no user. Each remap is one statement per target, compares values exactly and refuses a column too narrow for the new ids; a bad id map is refused before anything runs.0.5.0
\nusers.json (format 2) instead of users.csv. A users.csv, or a package from before 0.5.0, is refused: re-export it with this version.mu_migration/export/user/headers filter is removed; what the mu_migration/export/user/data filter returns travels without it.--blog-id, --new-url, --old-url …); the underscore forms 0.4.0 took are refused, naming the new one. Flags take no value and cannot be negated.import tables and import users require --blog-id; import all requires --new-url or --same-url; import tables requires --old-url with --new-url, or --same-url. Without --blog-id, the exports read the site WP-CLI runs against, not blog 1.--yes skips it) and is refused when nobody could answer, and each dangerous effect needs its own acknowledgement flag (--allow-main-site, --dangerously-allow-drop-tables and the others listed above).--dry-run stops there. --format=json prints the plan and outcome as JSON Lines.--dangerously-allow-role-overwrite.--plugins and --themes, never over an installed copy; uploads are merged without replacing files.0.4.0
\n