Where to run it
Run the daemon anywhere that can reach what it backs up. Every option below runs the same
safegrd daemon with the same config. To move from one to another, copy
~/.safegrd.
| Where | Use it when |
|---|---|
| A service on the host | The database or files are on a VM or a server you can SSH into. |
| Docker Compose | The database runs in Compose, or you want the client tools without installing them on the host. |
| Kubernetes CronJob | You run on Kubernetes and an hourly pass is often enough. |
| Kubernetes with Helm | You run on Kubernetes and want the daemon resident, so a "Back up now" or a drill from the console starts within a minute. |
| GitHub Actions | You have no server to run it on, and a scheduled workflow can reach the database. |
| On SafeGrd | You do not want to run it on anything of yours. SafeGrd starts a machine for each backup, if your plan includes it. |
Whichever you pick, enroll the host once first (Install and enroll).
Enrolling writes ~/.safegrd/config.yaml, and with a customer-managed key it writes
the key file next to it. In a container, keep that directory in a volume or a Secret.
A service on the host
Run safegrd daemon install. It writes a systemd unit on Linux or a launchd agent
on macOS, and starts it. Daemon covers the unit, its environment
and its logs.
Docker Compose
Use the image ghcr.io/safegrd/cli. It includes pg_dump 18, the
MariaDB client, the MongoDB tools and a PostgreSQL 18 server for sandbox drills, and it runs as
its own user. The example
compose.yaml
runs it next to a PostgreSQL service and keeps its config and key in the
safegrd-home volume.
Use the claim code the console shows when you add a host. Enrolling with it writes the
surfaces into the config. If a surface's credential is
{from: env, name: APP_DATABASE_URL}, it reads its connection string from the
service's environment, and the password stays out of the config.
Size the volume for the largest database you back up, because a sandbox drill restores into a throwaway cluster there. With a customer-managed key, keep a copy of the key somewhere safe outside the volume.
Kubernetes CronJob
cronjob.yaml
runs safegrd daemon run --once every hour. Each pass backs up every surface that
is due, runs a drill if SafeGrd's server asks for one, and exits. Enroll on any machine, then
put the config and the key in a Secret:
With a SafeGrd-managed key, leave daemon.key out.
The CLI refuses a config or key file that other users can read. A Secret volume cannot be both
0600 and owned by the container's user, so an init container copies both files into an
in-memory volume at 0600. The daemon keeps its state (the last backup of each surface, the
weekly and monthly slots) on a small PersistentVolumeClaim, so a restarted pod does not take an
extra backup. concurrencyPolicy: Forbid stops two passes from backing up the same
surface at once.
cronjob.yaml sets up. With a SafeGrd-managed key, leave daemon.key out of the Secret.
A "Back up now" or "Drill now" from the console waits for the next pass. To wait less than an
hour, change schedule so the CronJob runs more often. To have them start within a
minute, run the daemon resident with the Helm chart below.
Kubernetes with Helm
The Helm chart
runs safegrd daemon run as a Deployment and reads the same Secret as the CronJob.
Install it from a clone of safegrd/cli:
Set existingSecret to the Secret's name (safegrd by default). Use
env to add the variables your surfaces read their credentials from.
A sandbox drill restores into a throwaway cluster on the state volume
(persistence.size, 2 Gi by default). Size it for your largest database plus a
quarter. If a drill would leave less than 5% of the volume free, it runs in memory instead,
and the console says so.
GitHub Actions
The GitHub Action backs up from a scheduled workflow. Its drills restore into a database it creates on the runner. For a walkthrough, see Back up Supabase with GitHub Actions.
The action backs up PostgreSQL, MySQL, MariaDB, MongoDB and SQLite from a connection string.
It also backs up a folder or a mailbox that your config names as a surface. Its
README has a workflow for each.
Each job on a GitHub runner starts empty, so use format: tar when you back up a
folder there.
On SafeGrd
Under Surfaces in the console, click Back up on SafeGrd and give it a connection string. For each backup, SafeGrd starts a machine that runs it. SafeGrd keeps the connection string encrypted and uses it only on that machine. How it works.