WP Manifestindependent plugin directory
manifest / updates / syncdb

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

★ 0stars
0forks

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.zip

DB 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 mysqli and openssl extensions
  • A MariaDB/MySQL secondary database whose user can create, alter, insert into, and drop objects

Installation

  1. Download wp-db-mirror-sync.zip from this repository.
  2. In WordPress, go to Plugins > Add New > Upload Plugin.
  3. Upload the ZIP, install it, and activate DB Mirror Sync.
  4. Open DB Mirror Sync in the admin menu.
  5. Enter and test the secondary database connection.
  6. Compare the databases before starting synchronization.

Alternatively, copy the repository files into a folder named wp-db-mirror-sync under wp-content/plugins/.

  1. Configure and test the secondary connection.
  2. Run Compare and review the reported differences.
  3. Run a synchronization and wait for it to complete.
  4. Enable the plugin's maintenance mode to freeze non-administrator traffic and background jobs.
  5. Run a final synchronization.
  6. Run Verify Exact Match and review any row-count-only results.
  7. Perform the database cutover outside this plugin.
  8. 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 constants
  • includes/ - synchronization, verification, storage, database, security, and admin components
  • includes/views/ - WordPress admin views
  • assets/ - admin JavaScript and CSS
  • tests/ - standalone PHP test suite
  • readme.txt - WordPress.org-style plugin documentation and changelog
  • uninstall.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.