Documentation

Last updated: 2026-12-03

Backups

Everything an Everlock server holds is in bare git repositories in its data directory: users and configuration in everlock-system, mail, DNS zones, photo libraries, sites, and every repository created with /git create. A backup is a copy of those repositories, made with git, plus a record of how they looked on earlier days.

A backup has three parts:

  • A mirror of every repository, fetched on a schedule. It holds the server's current state on another disk.
  • Read-only snapshots of the mirrors. They hold the state of earlier days, including the days before a mistake reached the mirror.
  • A restore test. It shows that a snapshot can become the server's data directory.

What to copy

Every *.git directory in the data directory. Next to them are the binary and everlock-updates/, the self-update's staging area; both come from the download page again, so a backup leaves them out.

The backup reads the repositories over SSH, through the git-ssh backend, with an account that can read each of them, such as admin. In the admin console, /git repo list names every repository that account can read, the stores included. A store or repository created later appears there and joins the backup once the backup's list has it.

The backup holds the user records, credentials and certificates of the server, so it needs the same protection as the server itself.

A backup run

Once per repository, a bare mirror:

git clone --mirror ssh://admin@your-host:2222/everlock-system \
  /backup/everlock/everlock-system.git
git -C /backup/everlock/everlock-system.git config maintenance.auto false
git -C /backup/everlock/everlock-system.git config gc.auto 0

Use the SSH port from your everlock-ssh.socket. A mirror carries every ref — branches, tags, pull-request refs — and no checkout, so it costs what the repository costs.

Every run, a fetch per mirror and then a snapshot of the whole tree. With the mirrors in a Btrfs subvolume:

for repo in /backup/everlock/*.git; do
  git -C "$repo" fetch --prune || echo "fetch failed: $repo" >&2
done
btrfs subvolume snapshot -r /backup/everlock "/backup/snapshots/everlock-$(date +%F)"

--prune removes the refs the server removed. The snapshot is read-only, and it keeps that day's refs and objects as they were.

Why the snapshots stay cheap

Git stores objects as files and never changes one once it is written. A fetch adds the new objects in new files and leaves the old ones alone, and a Btrfs snapshot shares every unchanged file with the live tree and with the earlier snapshots. A day's snapshot costs what that day added.

What rewrites files is git's automatic maintenance, which runs after a fetch and repacks objects into new pack files. Repacked data is new data to the filesystem: the live tree holds the new packs, and every snapshot that holds the old packs keeps its own copy of the same objects. maintenance.auto false and gc.auto 0 turn that off for the mirrors. Both are needed: git 2.54 repacks a mirror after a fetch with gc.auto 0 alone.

Force pushes and deleted branches

The mirror follows the server. A branch moved by a force push, a deleted branch or tag, or a write that replaced good data reaches the mirror with the next fetch. The snapshots from before that day hold the earlier state: the repository copied out of one of them has the branch as it was.

Retention

A repository under a retention policy keeps its window on the server, and a mirror keeps everything it has fetched. The backup is then the long-term archive. A backup that keeps a bounded history asks for it with a depth on each fetch, as Backups in the retention guide describes, and its snapshots keep each day's state for as long as the snapshots themselves are kept.

Restore

A whole server: stop the service, move the repositories aside, copy them from a snapshot, hand them to the service user, start it.

sudo systemctl stop everlock
sudo mkdir /var/lib/everlock-before-restore
sudo mv /var/lib/everlock/*.git /var/lib/everlock-before-restore/
sudo cp -a /backup/snapshots/everlock-2026-12-01/*.git /var/lib/everlock/
sudo chown -R everlock:everlock /var/lib/everlock
sudo systemctl start everlock

Each repository is replaced as a whole directory. A mirror keeps many of its refs in one packed-refs file, and git reads a ref's own file before that list: copied over an existing repository, a ref file the server wrote after the snapshot outranks the snapshot's entry, and the branch keeps pointing where it pointed before the restore. The moved-aside repositories keep the state the restore replaced, for a look at what went wrong.

One repository: stop the service, move that repository's directory aside, copy its directory from the snapshot in its place, start the service.

A restored repository holds its objects in the pack files the fetches wrote. Everlock reads them. Retention and the daily git.gc job reclaim loose objects, so the history in those packs stays on disk.

Testing the restore

Copy a snapshot to another machine, start Everlock on the copy, and sign in:

cp -a /backup/snapshots/everlock-2026-12-01 /tmp/restore-test
everlock serve --data-dir /tmp/restore-test --frontend-ssh

The admin account of the server signs in, and its repositories, mail and libraries are there. That answers the question a backup exists for: whether this copy can become the server.

deployment backup git operations