Skip to content
Install

Schedule database dumps

The Helm chart can run pg_dump on a schedule and upload each dump to S3-compatible storage. Use it for Postgres databases that Orchard does not back up itself, such as the control-plane database, so that you have a copy off the cluster. Databases that Orchard manages have their own backups and point-in-time restore.

The chart creates one CronJob for each target.

  • Access to the chart values for the instance.
  • A bucket in S3-compatible storage.
  1. Create a Secret for the storage credentials. The default name is database-dumps-r2. The Secret needs the keys ACCESS_KEY_ID and ACCESS_SECRET_KEY.

  2. Create a Secret that holds the database password for each target. The default key is password.

  3. Add the following to your chart values:

    databaseDumps:
    enabled: true
    schedule: '15 2 * * *'
    destination:
    bucket: my-dumps
    endpointURL: https://s3.example.com
    targets:
    - name: orchard
    host: postgres.orchard.svc.cluster.local
    database: orchard
    user: orchard
    passwordSecret:
    name: orchard-postgres
  4. Apply the chart.

To list the CronJobs, run the following command:

kubectl get cronjobs -A | grep dump-

Each CronJob is named dump-<target name>. Each dump uses the pg_dump custom format.

KeyDefaultDescription
databaseDumps.enabledfalseCreates the CronJobs.
databaseDumps.schedule15 2 * * *The cron schedule, unless a target sets its own schedule.
databaseDumps.imagepostgres:17.12-alpineThe dump image. Keep the Postgres major version at or above the server’s.
databaseDumps.uploaderImageamazon/aws-cli:2.40.2The upload image.
databaseDumps.destination.bucketEmptyThe bucket. Required when there are targets.
databaseDumps.destination.prefixplatform-dumpsThe key prefix.
databaseDumps.destination.endpointURLEmptyThe S3 endpoint, for storage other than AWS.
databaseDumps.destination.secretNamedatabase-dumps-r2The Secret with the storage credentials.
databaseDumps.destination.keep0The number of dumps to keep for each target. 0 keeps every dump.
databaseDumps.targetsEmptyThe databases to dump.

Each target needs name, host, database, user, and passwordSecret.name. The optional keys are port (default 5432), namespace (default the top-level namespace value, orchard), schedule, and passwordSecret.key (default password).

Each dump goes to <prefix>/<target name>/<UTC timestamp>.dump in the bucket.

  • Go to production - Back up the control-plane database and prepare an instance for real users.
  • Add S3 storage - Configure the object storage that database backups and uploads use.