Previews, DB Cloning & Promotion
Ephemeral preview environments with automated database cloning and zero-downtime promotion
Explita Deploy provides built-in preview environments that let you test feature branches in complete isolation before releasing to production—including automated cloning of your production database.
The Preview Workflow
When testing complex pull requests or schema migrations, mock data is rarely enough. Explita Deploy solves this by orchestrating an isolated container with its own cloned copy of your live PostgreSQL or MySQL database:
┌──────────────────────────────────────────────┐
│ Production Deployment │
│ Container: web-app:prod (Port: 4100) │
│ Database: postgres://user:***@host/db_prod │
└──────────────────────────────────────────────┘
│
--preview --clone-db │ (clones schema & data)
▼
┌──────────────────────────────────────────────┐
│ Isolated Preview Deployment │
│ Container: web-app:preview-d79 (Port: 4101) │
│ Database: postgres://user:***@host/db_d79 │
│ URL: https://preview-d79.tunnel.explita.ng │
└──────────────────────────────────────────────┘
│
eda promote d79 │ (Zero-Downtime Traffic Swap)
▼
┌──────────────────────────────────────────────┐
│ Promoted to Live Production! │
└──────────────────────────────────────────────┘1. Deploying a Preview
To deploy your local branch as an isolated preview, add the --preview flag:
eda --previewSpecifying a Custom Preview Subdomain or Domain
By default, the server generates https://preview-d<id>.tunnel.explita.ng. You can customize the subdomain prefix or attach a preview domain:
# Custom subdomain prefix: e.g. "feat-auth-d79.tunnel.explita.ng"
eda --preview -s feat-auth
# Dedicated staging domain:
eda --preview -s staging -d staging.mycompany.com2. Automated Production Database Cloning
To clone your production database so your preview container has real-world data to test against, pass --clone-db:
eda --preview --clone-dbAdvanced Cloning Options:
--clone-db(Default): Clones the primary database configured under the"default"key.--clone-db default,analytics: Clones multiple specified database instances.--clone-db all: Clones all managed databases attached to the application.
How Database Cloning Operates:
- The deploy server extracts the schema, sequences, tables, and data from the production database.
- It provisions a temporary isolated database instance (e.g.
preview_db_d79). - It imports the snapshot into the temporary database.
- It injects the new connection string into the preview container's
DATABASE_URLenvironment variable. - Your production database is completely isolated and never modified by preview operations.
3. Promoting a Preview to Production
Once you have verified your preview URL, tested your endpoints, and confirmed your database migrations:
Important: The CLI command to promote a deployment is
eda promote <deploymentId>(noteda preview promote).
# Example: Promote deployment d79
eda promote d79
# If your server enforces DEPLOY_PASSCODE, pass it inline or enter it when prompted:
eda promote d79 --pass secret-pin-9876[!NOTE] Passcodes are never stored in config files. Passcodes/PINs are kept in the operator's mind and never saved to
explita.jsonor global CLI config files. If not provided inline via--pass,edainteractively asks🔑 Enter deploy passcode / PIN:.
What Happens During Promotion:
- The preview container's internal port is re-bound to the production service pool.
- Production custom domains (e.g.
myapp.com) are atomically updated in Caddy with zero downtime. - The previous production container is gracefully drained and stopped.
- The deployment status is updated to
PROMOTED.
4. Discarding & Purging Previews
If you decide not to release the preview branch, discard it to release server resources:
# Discard the preview deployment
eda rollback <deploymentId>
# Discard and permanently purge database records and temporary databases
eda rollback <deploymentId> --purgeThe --purge flag drops the temporary cloned preview database, destroys the container, and prunes the record from deployment history so it does not clutter your dashboard.
5. Cancelling In-Flight Deployments
If you triggered a deployment by mistake or pushed incorrect code:
# Cancel an active build or deployment
eda cancel <deploymentId>
# Or cancel the current project's active deployment
eda cancelPro Tip: Pressing
Ctrl + Cin your terminal whileedais streaming live deployment logs automatically sends a cancellation signal to the server, stopping the Docker build and pruning temporary build files immediately.