Gitea backup & restore

A self-designed backup system for a Git server and Docker services with an air-gapped NAS as the target.

Two sources, the Git server Gitea with 57 repositories and a Docker host with 13 services, pass through the same verified pipeline. The target is a NAS with RAID-1 that is switched off about 99 % of the time; the backup machine wakes the NAS via Wake-on-LAN and shuts it down only if it woke it itself. Anything is deleted only if at least two verified-good copies remain.

Stack
Bash · systemd timers · Wake-on-LAN · SHA-256 manifests · git fsck and SQLite checks · Gitea · Docker · mail alerting · Claude Code
Timescale
Design from 08.08.2026 · first commit 04.09.2026 · live since 27.10.2026.
Role
I completed this solo build with AI agents, where the architecture and every approval lay with me.
Scope
The scope includes a strategy document with 1,249 lines, a README with 482 lines, and 9 Bash scripts with 928 lines, all shellcheck clean.

Dual Source Infrastructure

The backup system protects a private homelab from two sources, the Git server Gitea with 57 repositories and a Docker host with 13 services. The services in the Docker host include cloud, chat, monitoring and custom apps. From the Docker host the configuration, Compose files, volumes, bind-mount data, systemd units and crontab are backed up, around 48,000 files. Both sources pass through the same verified pipeline; the backup runs every 14 days; a daily due-check decides whether it is due.

Air-gap NAS Strategy

The target is a NAS with RAID-1 (2 × 12 TB) that is switched off about 99 % of the time. The backup machine wakes the NAS via Wake-on-LAN and remembers beforehand whether it was already on. The backup machine shuts the NAS down again only if it woke the NAS itself. On the NAS, per source, the 4 newest runs, 1 monthly copy and 1 yearly copy are kept.

Integrity and Verification

Before the run, a preflight with more than 25 checks, git fsck over all repositories and a SQLite integrity check run. During the run, structure tests of the archives, plausibility thresholds against the previous run and a SHA-256 manifest per run apply. After the run, the NAS itself verifies what arrived there; promotion is atomic and happens only after the checks pass. Anything is deleted only if at least two verified-good copies remain.

Controlled Docker Backup

For a consistent archive the containers are stopped briefly. Afterwards the system restarts exactly the containers that were running before, also on error or abort. A stub test proves for 5 failure cases that exactly one restart always happens. Measured was a planned 135-second pause of the services; compression shrank the archive from 2.1 GB to 643 MB.

Monitoring and Acceptance

A daily dead-man switch reports when the chain falls silent; in addition there are a daily self-test and mails on start, success and failure. During review it turned out that the dead-man alert message would never have been sent before; this was fixed before going live. A backup that was never restored is a hypothesis; that is why the restore test is the acceptance. On 27.10.2026 the newest run was restored into an isolated throwaway container, where Gitea ran and the counts matched exactly (57 repositories, 3 users).

Development and Scope

The author is architect and client; the implementation was done with AI agents, with Claude Code handling planning, review and a live check after every step. The author approved every risky action personally. During setup the checks caught a misconfiguration that would have deleted other backup folders, before it became active. The strategy document has 1,249 lines; the 8 Bash scripts on the host and the 1 script on the NAS have 928 lines together.

Get in touch

Are you interested in a walkthrough?

The source code is private, but I am happy to walk through the architecture and the code on a call, NDA-friendly.

Contact