Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

Migration and recovery

Rehearse a logical migration, verify restored objects and check encrypted storage.

Plan the move

Build a fresh target cluster with the matching kernel, module and SQL installation. Migrate application objects and data logically. An old OpenHalo data directory, a physical pg_upgrade from that line, and ALTER EXTENSION aux_mysql UPDATE have no supported path to this fresh pg_mysql 1.0 installation. Keep the original DDL: old catalogs may already have lost a prefix length, binary width or generated expression.

Inventory PostgreSQL roles, owners, grants and schema dependencies separately from rows. Translate application objects that refer to historical extension names or C libraries. Decide how to represent uint64, durations, zero dates, ENUM/SET, NUL and collated keys before loading. Examples and alternatives

Restore a native archive

For a same-version Mimus rehearsal, use the matching PostgreSQL 19 tools. This example runs on the quick-start cluster using its native local socket as the database administrator. It restores schema app into a new database. The role app_user already exists cluster-wide; create reviewed roles and grants on a different cluster before restoring. Include external dependencies separately when selecting a single schema.

pg_dump -Fc -n app -f app.dump postgres
createdb restore_check
psql -X -v ON_ERROR_STOP=1 -d restore_check -c 'CREATE EXTENSION pg_mysql'
pg_restore --exit-on-error --single-transaction -d restore_check app.dump
psql -XAt -d restore_check -c 'SELECT id, body FROM app.notes ORDER BY id'
# 1|hello

Keep security labels and metadata triggers for MySQL definitions, including pending foreign keys. Preserve owners and reviewed privileges. Use native psql for inspection of restore_check; the MySQL listener continues to enter its configured database. To check restored MySQL behavior on another target, set that isolated instance’s mysql.database to the restored database and reconnect.

Restore a MySQL SQL dump

The 19.0.1 round trip used Oracle MySQL 5.7.32 tools. Run mysqldump --version before exporting. Tools shipped under the same command name can differ: MariaDB 10.5’s dump client can include generated column values that cannot be inserted. Stop source writes and DDL for this rehearsal, or arrange a separately verified consistent snapshot. The example uses TCP and interactive passwords. Supply the TLS identity options and CA for your endpoints.

set -e
mysqldump --protocol=TCP -h "$SOURCE_HOST" -P 3306 -u app_user -p \
  --ssl-mode=VERIFY_IDENTITY --ssl-ca="$SOURCE_CA" \
  --no-tablespaces --skip-lock-tables --hex-blob --skip-triggers app notes > notes.sql
mysql --protocol=TCP -h "$TARGET_HOST" -P 3306 -u app_user -p \
  --ssl-mode=VERIFY_IDENTITY --ssl-ca="$TARGET_CA" app < notes.sql

These two commands copy only the quick-start table. Its only trigger is maintained by pg_mysql for auto-increment. With the default trigger export, Oracle 5.7.32 exited with status 2 after writing the row, leaving a partial file. With --skip-triggers, export exited 0, table DDL recreated the identity behavior, and the first new insert after restore received ID 2. Check the exit status before replay. For tables with business triggers, use the native archive or separately translate, restore and exercise every trigger. For the schema-level test below, trigger export stayed at its default.

Use a fresh target instance, initialize the extension and create the empty app schema for its owner. The dump account needs read and view-definition privileges on its objects, the restore account must be able to create and populate them. Replay through the MySQL port to preserve quoting, executable comments and session variables. In the fixture, both archive paths preserved binary bytes, generated values, the view and prefix primary key. The tests checked new-orphan rejection, historical orphans, binding a missing parent, and cascading deletes after restore. Restoring this dump on an independent Oracle MySQL server was outside this run.

Verify encrypted tables

Before using ENCRYPTION='Y', preload both pg_tde and pg_mysql, install both in the target PostgreSQL database and configure its key provider and principal key. The MySQL clause selects the table access method. A displayed ENGINE=InnoDB is compatible spelling. Check the PostgreSQL access method and encryption flag to identify the actual storage. A logical dump contains readable data and requires protection of its own. Prepare keys on the restore destination and check physical encryption after loading. PG TDE setup and key management

CREATE TABLE sealed (id INT PRIMARY KEY) ENCRYPTION='Y';
INSERT INTO sealed VALUES (7);
CREATE TABLE sealed_copy LIKE sealed;
SHOW CREATE TABLE sealed;
SELECT id FROM sealed;

In mysql, the definition included ENCRYPTION='Y' and the row read back as 7. In native psql -d postgres, the following returned notes | heap | f, sealed | tde_heap | t, sealed_copy | tde_heap | t, and sealed_pkey | btree | t. The primary index still reports its index access method; check the encryption flag separately.

SELECT c.relname, a.amname, pg_tde_is_encrypted(c.oid)
FROM pg_class c JOIN pg_am a ON a.oid = c.relam
WHERE c.relnamespace = 'app'::regnamespace
  AND c.relname IN ('sealed', 'sealed_copy', 'sealed_pkey', 'notes')
ORDER BY 1;

The full-kernel two-node test also read a MySQL write via TDS and a TDS write via MySQL, with encrypted tables and primary indexes on both nodes. Explicit ENCRYPTION='N' requests heap and is subject to the database encryption policy. Rehearse encrypted recovery with your actual key provider; the logical round-trip fixture above used ordinary tables.

Cut over and roll back

  1. Rehearse on a separate target. Compare row counts and key ranges, HEX of binary values, collated duplicates, orphan counts, generated values, next identity value, ownership and application grants. Test a commit and a rollback over the actual driver.
  2. Quiesce source writes, drain open transactions, take the final consistent export and repeat the comparisons. MySQL GTID replication is unavailable (@@gtid_mode='OFF', both GTID sets empty). A PostgreSQL WAL position cannot resume a MySQL GTID stream.
  3. Switch application connections and keep the source and backup intact. Before the first target write, rollback can route clients to the source. After any target commits, stop writes and reconcile those transactions before reopening the source.