Backups

Scheduled copies of databases and caches to a bucket, with restore.

Overview

A backup copies a database or a cache to a bucket on a schedule and keeps the last few copies. From any copy you can restore, into the same database or into a new one.

When to use it

  • Every database holding data you can’t lose.
  • Before a risky change, with Back up now.
  • To keep copies off the machine, in an outside S3-compatible bucket.

How it works

Logical dumps
pg_dump in custom format for PostgreSQL; a fresh RDB snapshot for Redis; each engine’s own dump.
Streaming upload
The dump streams straight into a multipart upload (16 MiB parts) with a SHA-256 checksum, never kept whole in memory.
Scheduler
The same cron scheduler as jobs; old copies past your keep count are removed.

Each run dumps the source inside its own container and uploads the stream to the bucket. Restoring checks the checksum first; replacing an existing database takes a safety backup before it.

Architecture

Backups architectureA backup streams a dump into a bucket; restore reads it back.dumpstreammultipartSchedulerDatabase or cacheStreaming uploadSHA-256 checkedBuckethere or outside S3
A backup streams a dump into a bucket; restore reads it back.
  • Scheduler to Database or cache: dump
  • Database or cache to Streaming upload: stream
  • Streaming upload to Bucket: multipart

Flows

A nightly backup

  1. At the scheduled time the run starts.
  2. The engine’s dump tool writes to a stream that goes straight to the bucket.
  3. The run records its size and checksum; the oldest copies beyond Keep are removed.

Restoring

  1. Choose a run and Restore, into a new database or the same one.
  2. The checksum is verified first.
  3. Replacing takes a safety backup before writing.

Set it up

In the console

  1. Open Backups and choose New backup.
  2. Choose the database or cache, the bucket, the schedule and how many to keep.
  3. Use Back up now to try it.

With the CLI

enclave backup create orders-nightly --source database/orders --bucket uploads --schedule "0 3 * * *" --keep 7 --wait

With OpenTofu

OpenTofu configuration
resource "enclave_backup" "orders_nightly" {
  name     = "orders-nightly"
  source   = { database = "orders" }
  bucket   = "uploads"
  schedule = "0 3 * * *"
  keep     = 7
}

Settings reference

Every setting and output of the OpenTofu resource; the console and the CLI use the same names in their own words. Generated from platform 4d30582.

enclave_backup
NameTypeUseWhat it does
nametextrequiredName of the backup: 3–40 lowercase letters, digits or hyphens, starting with a letter. Changing it replaces the backup.
sourcelist of objectsrequiredWhat to back up: { database = … } or { cache = … }. Changing it replaces the backup.
buckettextoptionalStore backups in this EnclaveStack bucket. Exactly one of bucket or s3.
keepnumberoptionalKeep this many backups (1–365).
keep_daysnumberoptionalAlso delete backups older than this many days (0: no age limit). The newest is always kept.
prefixtextoptionalObject key prefix.
projecttextoptionalThe project to create it in. Defaults to the provider's project (ENCLAVE_PROJECT, else default). Changing it replaces the resource.
s3list of objectsoptionalStore backups in external S3. Exactly one of bucket or s3.
scheduletextoptional5-field cron or @hourly, @daily, @weekly, @monthly.
time_zonetextoptionalIANA time zone for the schedule (default: the machine's).
timeout_secondsnumberoptionalStop a backup after this many seconds (60–86400).
idtextoutputResource ID.
last_run_statustextoutputsucceeded, failed, timed_out or skipped.
last_success_attextoutputWhen the last backup succeeded (RFC 3339).
next_run_attextoutputWhen the next backup is due (RFC 3339).

Limits and security

Good to know

  • A bucket on the same machine doesn’t protect against losing the machine; use an outside bucket for that.

Security

  • Outside S3 credentials are read from a secret; passwords go to dump tools through the environment, never as arguments.