Skip to content

Backup

LiMDM backs itself up: a scheduled job writes an encrypted, signed archive to one or more storage targets on freely configurable schedules, keeps archives by a retention rule per schedule, verifies them and reports failures. Restores run on the command line. Point in time recovery of PostgreSQL stays a database task (Backup); the archive is the complete, portable copy of one moment.

Set it up under Settings, Backup (global admins only).

What an archive holds

One archive per run, limdm-<public host>-<UTC time>.lbk:

Entry Content
db/<table>.tsv every table as a PostgreSQL COPY text export, all from one read only snapshot (repeatable read), in restore order
ca/ the CA directory: device and network CA, command key, keys.json, audit-keys, audit-keyed-from, without the release cache. With an HSM only the certificates and these files
artifacts/ uploaded packages when they are stored locally (Package repository)
manifest.json server version, schema hash, table columns, sequences, the SHA-256 of every entry, keys.json (the active and retiring key generation of every kind), the device CA fingerprint, the audit head (last id and hash), the identifier of the session key
manifest.sig Ed25519 signature of the manifest with the command key

The tar is compressed with gzip and encrypted with age to the X25519 recipients set in the console. The format is open: age -d -i key.txt FILE.lbk | tar -tz lists an archive without LiMDM.

Not in the archive: LIMDM_SESSION_KEY. Sealed values in the database (recovery keys, client secrets, target secrets) need it, so it is kept apart, for example in a password safe with the age private key held by another person. The manifest names it only by an identifier derived with HKDF, which lets a restore check that the right key is set. Encrypting the archive with the session key itself would make it unreadable exactly when the server is lost.

Why COPY and not pg_dump: the server image is static and contains no PostgreSQL client, and pg_dump must match the server's major version. The COPY export runs over the server's own connection, needs no extra binary and is restored by the same code that knows the schema. For PITR or a dump of the whole cluster, use pg_dump or pgBackRest next to it.

Setup

  1. Create an age key pair offline: age-keygen -o limdm-backup.agekey. Keep the file in a safe or on a hardware key; enter its public key (age1...) as recipient. Two recipients let two people restore independently.
  2. Add targets (local, S3, Backblaze B2, SFTP, WebDAV):
Kind Use Notes
local a directory, also an NFS or SMB mount written as <dir>/<archive> with mode 0600
S3 AWS S3, MinIO, Ceph, Hetzner Object Storage, Wasabi, Backblaze B2 (S3 API), GCS with HMAC keys Signature V4; path style URLs for most non AWS services. Object Lock: archives are written with GOVERNANCE or COMPLIANCE retention for the set days; the bucket must have been created with Object Lock
SFTP any SSH server the host key is pinned (ssh-keyscan HOST line or SHA256: fingerprint); password or OpenSSH private key
Backblaze B2 B2 buckets its own target kind: region (from the bucket endpoint, for example eu-central-003), bucket, application key id and application key. Uses B2's S3 compatible API (see below); file lock works like Object Lock when the bucket has it enabled
WebDAV Nextcloud, ownCloud, Hetzner Storage Box, Apache mod_dav https only; the folder URL (Nextcloud: https://HOST/remote.php/dav/files/USER/limdm, Storage Box: https://uXXXXX.your-storagebox.de/limdm); with a user name the secret is the password (use an app password), without one a bearer token. Folders are created with MKCOL, archives streamed with PUT, listed with PROPFIND (depth 1), expired with DELETE

S3, B2 and WebDAV requests follow no redirects. Through an outbound proxy from the environment (HTTPS_PROXY, http or https proxies) the server resolves the target itself and tunnels to that address; private networks are fine, loopback and link local addresses (cloud metadata) are refused.

Large archives go to S3 and B2 as multipart uploads in parts of 256 MiB (a single PUT takes at most 5 GiB); every part carries its Content-MD5, the lock retention is set when the upload starts, and a failed upload is aborted so no parts stay behind.

Why B2 runs over its S3 API: Backblaze supports the S3 API for every bucket created since 2020, including multipart uploads for large files and Object Lock (B2 file lock) with the same headers. One tested client covers both, instead of a second implementation of the native B2 API (authorize, upload URLs, b2_start_large_file). Admins still enter B2 credentials directly; the endpoint https://s3.<region>.backblazeb2.com is derived from the region. Buckets from before 2020 without S3 support need a new bucket.

Other services (Azure Blob, Google Drive, Dropbox): mount them with rclone (rclone mount remote: /srv/backup) or point an rclone serve sftp / serve s3 / serve webdav at them and use the matching target. Test writes, reads and deletes a probe object and shows whether Object Lock is on. 3. Add one or more schedules (below), each with its targets and retention. Without a schedule, backups run only by hand, after key rotations and before upgrades.

The 3-2-1 rule indicator turns green with two or more targets, one of them not local and one with Object Lock: a compromised server or admin account can then not delete the last copies.