Built-in Backups: Let Test Restore use a database I create myself (for hosts without CREATE DATABASE)
In short: Test Restore is one of the best parts of the new Built-in Backups: it proves a backup can actually be restored. But on many hosts it can never run, because it insists on creating its own temporary databases. Please let us point it at a database we create ourselves instead.
Why this matters
A backup is only worth something if it can be restored. Test Restore checks exactly that, automatically, without touching the live site. That’s a big deal for anyone looking after client sites.
What happens today
Test Restore needs the Dashboard’s database user to create and drop databases named mainwp_tr_*. On many hosts this is simply not possible. Databases can only be created through the hosting control panel, never by a database user.
My host (Artfiles, Germany) confirmed this in writing: database users can’t create additional databases on their platform. They suggested creating a database through their control panel or API, or running a separate database container. The current Test Restore can use neither of those. So on these hosts Test Restore stays off permanently, and the Dashboard shows a warning that we can’t fix.
Proposal
Add an optional setting for a dedicated test database, either as fields in Backup Settings or as constants in wp-config.php:
php
define( 'MAINWP_TEST_RESTORE_DB_NAME', 'restore_test' ); define( 'MAINWP_TEST_RESTORE_DB_USER', 'restore_test' ); define( 'MAINWP_TEST_RESTORE_DB_PASSWORD', '...' ); define( 'MAINWP_TEST_RESTORE_DB_HOST', 'localhost' );When it’s set, Test Restore imports into this database using a unique table prefix for each run and drops those tables afterwards. When it’s not set, nothing changes.
Safety
Refuse to run if the test database is the same as the Dashboard’s own database.
Only ever drop tables carrying the current run’s prefix.
Nice to have: a filter or hook to create and remove the database on demand, for hosts that offer an API for this.
Who benefits
Everyone on shared or managed hosting where databases are created only through a control panel. That’s a large share of agencies and freelancers running MainWP.
Background: Community thread. Bojan suggested posting the idea here.
I’m happy to test a beta on my setup.
Log in to comment and vote
No comments yet
Be the first to share your thoughts.