DB Mirror Sync
WordPress plugin for resumable one-way MariaDB/MySQL database mirroring and verification
by Jens Hoevelmann and GitHub Copilot · github.com/tripmaster7/syncdb · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/tripmaster7/syncdb/archive/refs/heads/main.zipDB Mirror Sync is a self-contained WordPress plugin for comparing a live WordPress database with a secondary MariaDB/MySQL database and performing a resumable, one-way, exact-mirror synchronization in short background batches. It is designed for shared hosting environments and databases up to a few hundred megabytes.
Warning Synchronization is destructive on the configured secondary database. Objects that exist only on the secondary are removed, and primary tables and views are rebuilt there. The primary WordPress database is read-only to the plugin.
Features
- Configures and tests a secondary MariaDB/MySQL connection.
- Encrypts the stored secondary database password with AES-256-GCM using the WordPress authentication salts.
- Compares table and view existence, structure, and approximate row counts.
- Mirrors tables, data, indexes, foreign keys, and views from primary to secondary.
- Runs in time-bounded, resumable batches with progress, cancel, retry, and resume controls.
- Prevents synchronization when the secondary points to the primary database.
- Verifies common tables with exact row counts and extended checksums.
- Falls back to row-count verification for very large tables to stay within shared-hosting execution limits.
- Provides an administrator-only maintenance mode that returns HTTP 503 to other traffic while final synchronization and verification are performed.
- Requires no shell access, WP-CLI, Composer, or external service.
Stored procedures, triggers, and events are not mirrored. The plugin does not switch WordPress to the secondary database; production cutover remains a separate manual operation.
Requirements
- WordPress 5.8 or newer
- PHP 7.4 or newer
- PHP
mysqliandopensslextensions - A MariaDB/MySQL secondary database whose user can create, alter, insert into, and drop objects
Installation
- Download
wp-db-mirror-sync.zipfrom this repository. - In WordPress, go to Plugins > Add New > Upload Plugin.
- Upload the ZIP, install it, and activate DB Mirror Sync.
- Open DB Mirror Sync in the admin menu.
- Enter and test the secondary database connection.
- Compare the databases before starting synchronization.
Alternatively, copy the repository files into a folder named
wp-db-mirror-sync under wp-content/plugins/.
Recommended cutover workflow
- Configure and test the secondary connection.
- Run Compare and review the reported differences.
- Run a synchronization and wait for it to complete.
- Enable the plugin's maintenance mode to freeze non-administrator traffic and background jobs.
- Run a final synchronization.
- Run Verify Exact Match and review any row-count-only results.
- Perform the database cutover outside this plugin.
- Disable maintenance mode after validating the site.
The verification checksum cutoff defaults to 200,000 rows and can be changed before the plugin loads:
define( 'DBMIRROR_SYNC_VERIFY_CHECKSUM_ROW_LIMIT', 300000 );
Development
Run the standalone test suite from the repository root:
php tests/run-all.php
The runner syntax-checks every PHP file and tests the DDL helper, identity guard, job cursor, verification cursor, encryption, and plugin bootstrap without requiring PHPUnit, Composer, WordPress, or a live database.
Live WordPress and MariaDB/MySQL testing is still required to validate database connections, schema comparison, full synchronization, cron continuation, maintenance mode, and exact-match verification.
Project layout
wp-db-mirror-sync.php- plugin bootstrap and constantsincludes/- synchronization, verification, storage, database, security, and admin componentsincludes/views/- WordPress admin viewsassets/- admin JavaScript and CSStests/- standalone PHP test suitereadme.txt- WordPress.org-style plugin documentation and changeloguninstall.php- removes plugin settings and bookkeeping tables only
Security
Do not commit wp-config.php, environment files, database exports, private
keys, or local credentials. Secondary connection settings are stored in the
WordPress database, not in this repository, and the password is encrypted at
rest. If you discover a security issue, report it privately to the repository
owner rather than opening a public issue.
License
GPL-2.0-or-later. See the license metadata in the plugin source and
readme.txt.