Switching a site over, and back
HyScribe reads and writes the WordPress database as PHP WordPress does. It never changes the core tables’ schema and writes only rows PHP WordPress could have written. So the same database works with either, and switching back is stopping one and starting the other.
Read Not supported first: what a site needs and HyScribe answers 501 decides how far you can switch.
Before you start
Section titled “Before you start”- Back up the database and the uploads folder (see Maintenance)
- The site must be WordPress 7.0 or 7.1 (
db_version61833), single site, not multisite - Leave the WordPress folder in place. It is what you switch back to, and its
wp-content/uploadsstays where it is - Set up mail: HyScribe sends through an SMTP relay (
SMTP_HOSTand the keys beside it, Configuration), never through a localsendmail. Without one, comment notices and password reset links stop while it is primary
Rehearse on a copy
Section titled “Rehearse on a copy”The safest first step is a whole switch over and back on a copy of the site:
- Load the backup into a second database, and copy the WordPress folder
- Run HyScribe in primary mode against the copy (steps below), with
WP_HOMEandWP_SITEURLset to its own address - Do the site’s usual work in hs-admin: write and edit posts, moderate comments, change settings
- Stop HyScribe and serve the copy with PHP WordPress: check the same screens, with
WP_DEBUGon, and read itsdebug.log
1. Shadow mode beside PHP WordPress
Section titled “1. Shadow mode beside PHP WordPress”Shadow mode is read only. HyScribe opens no writer at all, so it cannot change the database whatever a request asks.
- Install and run the setup wizard against the site’s
wp-config.php, answering yes toStart in shadow mode (read only) first?(Install) - Optionally give a database user granted only
SELECT, so even a fault cannot write - Start it on its own address:
./hyscribe service start. PHP WordPress keeps serving the public site - Browse HyScribe on
127.0.0.1:8080(through an SSH tunnel if remote). If the stored site address sends you to the public site, setWP_HOMEandWP_SITEURLto HyScribe’s address in.envwhile trying it - Compare pages, feeds and the REST API with the live site
In shadow mode logins are off (the login screen says the site is read only), so hs-admin cannot be used, comment posts and other writes are refused with 403, and no scheduled job runs.
2. Primary mode
Section titled “2. Primary mode”Primary mode serves the site and writes to the database.
- Check the gaps once more: themes, plugins, uploads and mail (Not supported)
- Set
MODE=primaryin.env, remove anyWP_HOMEandWP_SITEURLused for trying, and setBEHIND_PROXY=trueif a proxy is in front ./hyscribe config check, then./hyscribe service restart- Read the log (
./hyscribe service log) forwrites refused:lines: HyScribe does not write to a table whose engine cannot roll back (MyISAM, for example; the line gives theALTER TABLE ... ENGINE=InnoDBthat converts it), nor to a database whosedb_versionit does not support - Read it for
cron:lines too: the scheduled core jobs run in the service unlessDISABLE_WP_CRONis set or anobject-cache.phpwas found - Check that
UPLOADS_DIRnames the site’swp-content/uploadsand that the service user can write it: HyScribe serves/wp-content/uploads/from there and writes new images there, where PHP WordPress finds them after a switch back. Then point the reverse proxy at HyScribe - Log in at
/hs-login(old/wp-login.phplinks redirect there)
Users log in again: HyScribe keeps its own sessions under sessions/, so a PHP WordPress login cookie does not carry over. Passwords do, through the same hashes and the copied keys and salts.
PHP WordPress beside it
Section titled “PHP WordPress beside it”PHP WordPress may keep running on the same database, for example for WP-CLI or a screen HyScribe answers 501, and the two are as safe together as two PHP servers. Two things to know:
- A persistent object cache (an
object-cache.phpdrop-in with Redis or Memcached) is not cleared by HyScribe’s writes, so PHP WordPress can show stale data until it expires. Flush it after HyScribe has written, and before switching back - HyScribe runs only WordPress’s core jobs. Plugins’ events and the update checks wait in the
cronoption until PHP WordPress runs its cron. To keep them running, have the system’s cron call PHP’swp-cron.phpas before; it takes the samedoing_cronlock as HyScribe, so the two never run events at once
Switching back to PHP WordPress
Section titled “Switching back to PHP WordPress”./hyscribe service stop- If the site uses a persistent object cache, flush it
- Point the reverse proxy back at PHP WordPress, including
/wp-content/uploads/ - Users log in again through
wp-login.php - Visit a page or run PHP’s cron once, so the events HyScribe left due (plugins’ events, update checks) run
Everything HyScribe wrote is in the WordPress tables, in WordPress’s format, and the cron option keeps every event. Uploaded images are in UPLOADS_DIR, the folder PHP WordPress already uses. HyScribe keeps only its login sessions and logs outside the database, in hyscribe/, which PHP WordPress does not need. Keep the hyscribe/ folder until you are sure; to remove HyScribe, delete it (for a site whose uploads live in hyscribe/uploads/, move them out first).
What the switch-back suite guarantees
Section titled “What the switch-back suite guarantees”Every release runs the switch-back suite (reference/switch-back/run.sh) on a fresh default WordPress install. The release binary makes 124 changes over HTTP, as an administrator and as visitors, among them:
- The dashboard: a Quick Draft, the welcome panel, box order and screen options
- Posts and pages: Quick Edit, bulk edit, trash, restore, delete, emptying the trash, restoring a revision, the edit lock
- Categories and tags: added, edited, renamed and deleted
- Comments: posted from the front end, moderated every way, replied to, edited and deleted
- Users: added, edited, promoted, given a reset link and deleted with their posts reassigned; the profile and color scheme
- Every Settings screen, two permalink structures and a static front page
- REST writes of posts, pages, navigation menus and synced patterns: created, updated, trashed and deleted
- A restart with
EMPTY_TRASH_DAYS=0, after which trashing deletes for good
Then PHP WordPress 7.1.3, on the same database with WP_DEBUG on, checks:
- Every option and meta value unserializes, and every user loads with a role WordPress knows
- The stored comment and term counts equal the ones WordPress recomputes
- What the options point at (sticky posts, front page, posts page, privacy page, default category) exists
- The rewrite rules HyScribe stored equal the ones WordPress generates, and work
- PHP’s REST read of each object HyScribe’s REST API wrote equals HyScribe’s answer
- 50 admin screens and front end pages, as the administrator, the user HyScribe added and a visitor, answer their status and show their text, with no PHP or database error
- PHP’s debug log stays empty
It does not yet cover the REST writes of terms, comments, users and settings, nor anything HyScribe does not do, and it runs on the default install, not on your site’s data. Rehearse on a copy, and keep the backup.
WordPress is a registered trademark of the WordPress Foundation. HyScribe is an independent project and is not affiliated with, sponsored by or endorsed by the WordPress Foundation or Automattic.
Code under AGPL-3.0-or-later. The HyScribe name and logo are not covered by that licence. HyScribe is a product of HyScaler.