Docs / Where to run it

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.

WhereUse it when
A service on the hostThe database or files are on a VM or a server you can SSH into.
Docker ComposeThe database runs in Compose, or you want the client tools without installing them on the host.
Kubernetes CronJobYou run on Kubernetes and an hourly pass is often enough.
Kubernetes with HelmYou run on Kubernetes and want the daemon resident, so a "Back up now" or a drill from the console starts within a minute.
GitHub ActionsYou have no server to run it on, and a scheduled workflow can reach the database.
On SafeGrdYou 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.

Choosing where to run the daemon. If nothing of yours should run it, run it on SafeGrd. If you have no server or VM, use GitHub Actions. If you have one and it is not Kubernetes, use a service on the host or Docker Compose. On Kubernetes, use Helm for a resident daemon that starts a console request within a minute, or a CronJob for an hourly pass. Run it on something of yours? On SafeGrd no yes Is there a server or VM it can run on? GitHub Actions no yes Is it Kubernetes? Service or Compose no yes Console requests must start within a minute? Helm resident daemon yes CronJob: a pass each hour no
The table above as a set of questions. Every option runs the same daemon with the same config.

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.

# 1. Enroll once: writes the config and key into the volume
docker compose run --rm safegrd enroll --token sg_pat_... --claim <code>
# 2. Start the daemon
docker compose up -d
# 3. Check it
docker compose exec safegrd safegrd doctor
docker compose exec safegrd safegrd list

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:

kubectl create secret generic safegrd \
  --from-file=config.yaml=$HOME/.safegrd/config.yaml \
  --from-file=daemon.key=$HOME/.safegrd/keys/daemon.key
kubectl apply -f cronjob.yaml

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.

How the CronJob gets its config. The Secret named safegrd holds config.yaml and, with a customer-managed key, daemon.key, mounted read-only. An init container copies both into an in-memory volume at mode 0600, because the CLI refuses a config or key others can read. Each hour the safegrd container runs daemon run --once from that volume, and keeps its state on a small PersistentVolumeClaim so a restarted pod takes no extra backup. Secret: safegrd config.yaml, daemon.key, read-only in-memory volume ~/.safegrd, each file 0600 daemon run --once every hour: 0 * * * * PVC state, 64 Mi init container install -m 0600 concurrencyPolicy: Forbid, one pass at a time
What 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:

helm install safegrd ./packaging/helm/safegrd

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.