Reusable, Windows-first WordPress development sandbox for restoring sites with UpdraftPlus, editing themes and plugins locally, testing changes away from production, and exposing the local site through ngrok HTTPS.
This project is for local development and testing. It does not deploy to or modify a production website.
- Install and start Docker Desktop using Linux containers.
- Clone or copy this repository.
- Double-click
start.bat. - Wait for the checks to finish. The browser opens at http://localhost:8080.
The first start creates an ignored .env from .env.example, starts MariaDB, WordPress, and WP-CLI, checks storage permissions and PHP limits, and leaves the installation ready for browser setup or restore.
PowerShell alternative:
.\scripts\setup.ps1
The scripts support Windows PowerShell 5.1 and PowerShell 7. The BAT launchers already use -ExecutionPolicy Bypass; changing the machine execution policy is not required.
| Command | Purpose |
|---|---|
start.bat |
Start and verify local WordPress |
ngrok.bat |
Expose WordPress over public HTTPS |
stop.bat |
Stop the complete sandbox and restore localhost mode |
.\scripts\doctor.ps1 |
Run diagnostics |
.\scripts\doctor.ps1 -VerifyUpdraftChecksums |
Also verify UpdraftPlus against WordPress.org |
.\scripts\logs.ps1 |
Follow the WordPress debug log |
.\scripts\logs.ps1 -Docker |
Follow container logs |
.\scripts\post-restore.ps1 |
Repair URLs after an Updraft restore |
.\scripts\local-admin.ps1 |
Create or restore a local administrator |
.\scripts\wp.ps1 <args> |
Run WP-CLI |
.\scripts\reset.ps1 |
Reset DB/core; preserve host content |
.\scripts\reset.ps1 -CleanWpContent |
Reset DB/core and delete host wp-content |
.\scripts\reset.ps1 -ForDistribution |
Remove all runtime/client data before sharing |
flowchart LR
A[start.bat] --> B[Localhost]
B --> C[Updraft restore]
C --> D[Edit wp-content]
D --> E[ngrok.bat]
E --> F[Public HTTPS]
F --> G[stop.bat]
start.bat is always the normal local entry point. ngrok is optional and never starts automatically.
| Data | Location |
|---|---|
| WordPress core | Docker volume wp_data |
| Database | Docker volume db_data |
| Themes, plugins, uploads | Host wp-content/ |
| Updraft backup archives | Host backups/updraft/ |
WordPress and WP-CLI mount the same host content tree. Edit these folders directly in VS Code, Codex, or another editor:
wp-content/themes/
wp-content/plugins/
Changes are visible without rebuilding an image or copying files into a container. PHP changes apply on the next request; CSS and JavaScript may require a hard refresh.
Runtime WP_HOME and WP_SITEURL come from WP_PUBLIC_URL, so a restored production database does not become the runtime URL source of truth. WordPress core and MariaDB remain Docker-managed.
When WP_INSTALL_UPDRAFTPLUS=true, setup runs wp plugin install updraftplus --activate. The updraftplus slug is downloaded by WP-CLI from the public WordPress.org plugin directory; the template contains no plugin ZIP or premium package. To verify an installed copy:
.\scripts\doctor.ps1 -VerifyUpdraftChecksums- Run
start.bat. - Copy every file from one Updraft backup set into
backups/updraft/. - In WordPress, open Settings ā UpdraftPlus Backups ā Existing backups.
- Select Rescan local folder for new backup sets.
- Restore the database, plugins, themes, uploads, and other content.
- Do not restore
wp-config.php. - Avoid restoring WordPress core unless a compatibility test requires it.
- Run the post-restore helpers:
.\scripts\post-restore.ps1 -SourceUrl "https://client.example" -DryRun .\scripts\post-restore.ps1 -SourceUrl "https://client.example" .\scripts\local-admin.ps1 .\scripts\doctor.ps1
Then edit the restored project directly, for example:
wp-content/themes/client-theme/
The URL replacement is serialized-data-safe, covers all tables with the configured prefix, skips GUIDs, and flushes rewrites and caches.
Copying archives into backups/updraft/ is also the reliable path for files above Apache's default 1 GiB HTTP request-body limit. PHP accepts up to 2 GiB, but the direct folder workflow avoids browser and reverse-proxy upload limits entirely.
A restored database may replace the temporary local account. Configure the ignored .env:
WP_LOCAL_ADMIN_USER=localadmin WP_LOCAL_ADMIN_PASSWORD=choose-a-strong-local-password WP_LOCAL_ADMIN_EMAIL=[email protected]
Then run .\scripts\local-admin.ps1. The helper only operates in the local development environment.
-
Add the token to the ignored
.env:NGROK_AUTHTOKEN=your-token
-
Run
start.bat. -
Run
ngrok.bat. -
Use the printed HTTPS URL.
-
Inspect requests at http://localhost:4040.
-
Run
stop.batwhen finished.
ngrok.bat waits for the local ngrok API, uses /api/tunnels as the URL source of truth, switches the runtime URL, recreates only WordPress and WP-CLI when their environment changed, and verifies both the tunnel and WordPress. Automated checks send ngrok-skip-browser-warning: 1; ordinary browser behavior is unchanged.
stop.bat stops ngrok together with WordPress, WP-CLI, and MariaDB. It also restores WP_PUBLIC_URL and stored content URLs to the localhost URL derived from HOST_PORT.
Power-user commands:
.\scripts\ngrok.ps1 .\scripts\local.ps1
Common settings live in the ignored .env:
HOST_PORT=8080 WP_PUBLIC_URL=http://localhost:8080 WORDPRESS_IMAGE=wordpress:php8.2-apache WPCLI_IMAGE=wordpress:cli-2.12.0-php8.2 MARIADB_IMAGE=mariadb:11.4
When changing the local port, keep HOST_PORT and WP_PUBLIC_URL aligned. start.bat derives the local URL from HOST_PORT and restores local mode automatically.
Optional automatic installation settings:
WP_AUTO_INSTALL=true WP_ADMIN_USER=admin WP_ADMIN_PASSWORD=choose-a-strong-local-password WP_ADMIN_EMAIL=[email protected] WP_INSTALL_UPDRAFTPLUS=true
memory_limit=1024M is PHP's per-request ceiling, not a Docker RAM reservation. Compose does not impose CPU or memory limits by default, so containers share the resources assigned to Docker Desktop/WSL2.
The default Windows workflow prioritizes direct editing: wp-content/ is a Docker Desktop bind mount. Large restored sites with thousands of PHP files can pay a noticeable Windows-to-Linux filesystem cost on every uncached request.
For maximum filesystem performance, keep the complete repository in the WSL2 Linux filesystem and open it with VS Code Remote - WSL. The BAT/PowerShell workflow on C:\... remains supported and is usually the simplest option. Do not move only wp-content; Compose paths are relative to the repository.
Before blaming resource limits, run .\scripts\doctor.ps1 and docker stats --no-stream. The doctor reports Docker capacity, container limits, OPcache, Xdebug, debug-log size, cache drop-ins, WP-Cron mode, and the effective wp-content storage type.
Debug logging stays enabled by default, warnings stay out of browser HTML, and SAVEQUERIES remains disabled. Long restore processing may run for up to 900 seconds, but the general PHP socket fallback remains 60 seconds so unavailable integrations cannot silently hold a request for 15 minutes. Plugins can still request a longer timeout for a specific operation. If a restored site is slow, inspect repeated log writes, production cache drop-ins, overdue cron, and the restored plugin/theme stack before changing server defaults.
| Command | DB/Core | wp-content |
Backups |
|---|---|---|---|
.\scripts\reset.ps1 |
Delete | Preserve | Preserve |
.\scripts\reset.ps1 -CleanWpContent |
Delete | Delete | Preserve |
.\scripts\reset.ps1 -ForDistribution |
Delete | Delete | Delete |
-CleanWpContentand-ForDistributioncan permanently delete local development or client files. Read the prompts and copy anything important elsewhere first.
All reset modes are scoped to this Compose project. A normal stop.bat is not a reset: it preserves both named volumes, host content, backups, .env, and source files.
| Problem | Practical check or fix |
|---|---|
| Docker Desktop is not running | Start Docker Desktop, wait for Linux containers, then run docker info and retry. |
| Port 8080 is occupied | Stop or reconfigure the owning process, or change HOST_PORT. The scripts never kill unrelated processes. |
| Docker prints daemon warnings | Warnings on stderr may be non-fatal; helpers use the native Docker exit code. Run doctor.ps1 if startup does not complete. |
| Compose config not found | Use the provided scripts. They always pass absolute project, Compose, and environment paths. |
| Upload exceeds the limit | Run doctor.ps1; prefer copying Updraft files into backups/updraft/ and rescanning. |
| Database connection error | Run doctor.ps1, logs.ps1 -Docker, and .\scripts\wp.ps1 db check. Reset only if the data is disposable. |
| Updraft backup not detected | Copy the complete matching backup set, verify backups/updraft/, then use Rescan local folder. |
| Site redirects to production | Run post-restore.ps1 with the exact source URL; inspect restored redirect/security plugins and .htaccess. |
| Local administrator is missing | Set WP_LOCAL_ADMIN_* in .env, then run local-admin.ps1. |
wp-content is not writable |
Rerun setup and doctor; confirm Docker Desktop can share the repository drive. Do not apply blanket chmod 777. |
| ngrok token is missing | Set NGROK_AUTHTOKEN in the ignored .env; never commit it. |
| Tunnel exists but the public URL fails | Open the inspector, read the categorized error from ngrok.ps1, and inspect the last 20 ngrok log lines printed on failure. The tunnel is left running for debugging. |
| Redirect loop through ngrok | Confirm WP_PUBLIC_URL equals the printed HTTPS URL; disable restored production-host redirect rules, then flush rewrites. |
| CSS/JS changes are not visible | Use Ctrl+F5 or disable the browser cache in developer tools; clear WordPress/cache-plugin caches if active. |
For application errors, follow wp-content/debug.log with .\scripts\logs.ps1. Browser output remains clean because debug display is disabled.
wordpress-sandbox/
āāā start.bat
āāā ngrok.bat
āāā stop.bat
āāā compose.yml
āāā wp-content/
āāā backups/
ā āāā updraft/
āāā docker/
āāā scripts/
All scripts resolve the repository root from their own path. They can be launched from another working directory without losing the Compose project context.
Client backups and restored sites may contain personal data, private uploads, email addresses, plugin API keys, credentials, and production configuration. A private repository is not a safe place for that material.
The repository intentionally ignores:
.env
wp-content/*
backups/updraft/*
Only .gitkeep placeholders remain versionable in the two data directories. Never commit client data, backups, database dumps, logs, tokens, or extracted production configuration. Before sharing the repository, run:
.\scripts\reset.ps1 -ForDistributionThen inspect git status and the working tree. Choose a license before any future public publication; this private template does not invent one.