Before WP Migrate DB Pro was around, the standard way to migrate your WordPress database from one site to another was to open up phpMyAdmin and make a MySQL dump of the WordPress Database, then use a text editor to find all instances of your old url and replace it with the new one, and finally use phpMyAdmin on the destination server to import the modified dump file, completely replacing any data that might have already been there.
WP Migrate DB Pro doesn’t do things too much differently than that: It simply automates the process by running the export, find and replace, transfer and import for you. It also refines certain steps such as ensuring that find and replace operations are properly applied to serialized data, preserving certain WordPress options for your convenience, and so on.
Anatomy of a Migration
A typical push or pull migration with WP Migrate DB Pro follows these steps:
- Local site sends an initiation request to the remote. If the secret key checks out and the migration is allowed (push or pull enabled on remote) the remote will respond, letting the initiating site know that it can proceed with the migration.
- Requests from the initiating site are sent securely via https and all data being transferred between sites is signed with the secret key to ensure that it is not altered, for instance by a “man in the middle” attack.
- For each table included in the migration, a temporary table is created in the destination database with a special prefix so that it doesn’t overwrite existing data.
- Data is read from the requested tables in the source database, find and replace operations are performed and the data is transformed into MySQL statements that will insert the data into the temporary tables in the destination database.
- In order to comply with POST size and memory limits set by each server the generated MySQL insert statements are transferred to the destination site in small chunks which are then executed on the destination database which will insert the data into the temporary tables.
- When all data has been transferred and is inserted into the temporary tables in the destination database, WP Migrate DB Pro will query the current source database for any options that were requested to be preserved (generally the list of active plugins) and copy that over to the corresponding entry in the temporary tables.
- Finally, each table that was transferred is renamed from its temporary name to the actual table name, if the table already exists in the destination database it is removed before the temporary version is renamed.
Why No Merging?
People often ask us if WP Migrate DB Pro can merge two databases. Usually they have a development site that has had some database changes and a live site that has had different changes made to it. This is incredibly difficult and error-prone since each row of data contains a unique ID that is often used to relate that row of data with other rows of data in the database. Attempting to merge two databases would mean that IDs would have to be changed and related data would get lost or mixed up unless WP Migrate DB Pro knew a great deal more about the way your database is set up than it actually does. WP Migrate DB Pro simply transfers data and overwrites any tables in the destination database that have been transferred from the source database.