Overview
Pre-deploy backups let your CI/CD pipeline take a snapshot of your database before a deployment runs, and block until the backup is confirmed stored in the cloud. If the backup fails, your pipeline fails — the deploy never happens.200 means the backup is safely in the cloud — it will appear in your dashboard under Backups. Any other status means it failed — your deploy script can handle it however you want.
How it works
- The API receives your request and creates a backup job
- It sends a signal to the Capsule daemon running on your server
- The daemon runs a full backup (dump → encrypt → upload to cloud storage)
- Once stored, the daemon reports completion back to the API
- The API returns
200with thebackup_idto your pipeline
Request
connection_label must match a connection configured in your Capsule CLI.
note is optional (max 1000 characters) — a free-text note recorded against the resulting backup, useful for tying a backup to a deploy, ticket, or commit. It’s write-once: set only when the backup is triggered, and cannot be edited afterward. It shows up in the dashboard’s Backups table and in capsule backup list.
Query parameters
Response
200 — backup completedcapsule daemon (or check systemctl status capsule).
502 — backup failed on the server
GitHub Actions
The easiest way to wire this into a GitHub Actions pipeline iscapsule-infra/backup-action, which wraps the same API call below as a reusable, versioned step:
CAPSULE_LICENSE_KEY. The action fails the step (and stops the job) automatically on any non-200 response, and exposes backup-id / job-id as step outputs — see the action’s README for the full input/output reference, timeout tuning, and a complete example workflow.
Prefer raw curl instead of the action?
CAPSULE_LICENSE_KEY. Functionally identical to the action above — useful if you’d rather not depend on a third-party action, or need custom logic the action doesn’t expose. note is optional — drop it from the payload entirely if you don’t want one.
Shell / bash deploy scripts
-sf flags make curl exit with a non-zero code on HTTP errors, so set -e will stop the script automatically if the backup fails.
Custom timeout
For large databases that take more than 5 minutes to dump and upload, pass?timeout=<seconds>:
Set
--max-time on your curl call to slightly more than the ?timeout= value so curl doesn’t give up before the API does.timeout value is 3600 (1 hour). Values above this are clamped to 3600.
Requirements
- Capsule daemon must be running on the server that hosts the connection (
capsule daemonor the systemd service) - The connection label must match exactly what’s configured in the CLI
- Your license key must be for the account that owns the connection