--- type: Guide purpose: Operate, restore from and troubleshoot the backups. answers: - "How are backups operated, restored and fixed?" cites: - scripts/gitea-backup --- # Backup Operations Running, restoring and fixing the backups once [11-backup-automated.md](11-backup-automated.md) is set up. ## Remote operation (from anywhere) No ports are exposed for this. Bring up the router's WireGuard tunnel on your laptop (setup and the router key-export bug check: [03 §7](03-ssh-hardening.md#7-remote-admin-wireguard-never-a-port-forward)): ```bash sudo systemctl start wg-quick@wg0 && sudo wg show wg0 # recent "latest handshake" ssh -p 2234 admin@192.168.1.50 ``` Then on the server: | Task | Command | |---|---| | When did it last run, did it pass? | `systemctl status gitea-backup --no-pager` | | Log of last run | `journalctl -u gitea-backup -n 60 --no-pager` | | Next scheduled run | `systemctl list-timers gitea-backup.timer` | | Back up now | `sudo systemctl start gitea-backup` | | List snapshots | `sudo gitea-backup snapshots` | | Full integrity check | `sudo gitea-backup check` | | Restore test | `sudo gitea-backup restore-test` | | Pause nightly backups | `sudo systemctl disable --now gitea-backup.timer` | ## Restore from a restic snapshot Not yet run against the live stack; `restore-test` proves the same mechanics. ```bash sudo gitea-backup snapshots # pick an ID, or use "latest" sudo mount -t ntfs3 /dev/disk/by-label/BACKUP /mnt/backup cd ~/mithlond docker compose stop gitea # Caddy keeps the apex site up sudo mv gitea-data gitea-data.broken sudo sh -c '. /etc/gitea-backup/env; export RESTIC_REPOSITORY RESTIC_PASSWORD_FILE; restic restore --tag gitea --target /' docker compose up -d gitea # up -d re-applies compose.yml env hardening cd ~ && sudo umount /mnt/backup ``` restic restores the absolute path `/home/admin/mithlond/gitea-data` with original owners — no `chown`. Check the site, then `ssh -T git@git.example.com -p 2222` (no host-key warning), then remove `gitea-data.broken`. ## Restore from a tar archive Not yet run against the live stack — [10](10-backup-manual.md) steps 7–12 prove the archive restores into a fresh Gitea, and these are the same mechanics. Verify the checksum first. ```bash cd ~/mithlond sha256sum -c /mnt/backup/mithlond/gitea-backup-YYYYMMDD-HHMM.tar.gz.sha256 docker compose stop gitea # only gitea — Caddy keeps the apex site up sudo mv gitea-data gitea-data.broken sudo tar -xzpf /mnt/backup/mithlond/gitea-backup-YYYYMMDD-HHMM.tar.gz -C ~/mithlond docker compose up -d gitea # up -d, not start: re-applies compose.yml env hardening ``` No `chown` needed — `tar -p` as root restores the original owners (`1000:1000` for data, `root:root` for `ssh/`). Check `https://git.example.com`, then `ssh -T git@git.example.com -p 2222` (no host-key warning = host keys came back), then remove `gitea-data.broken`. ## Troubleshooting | Symptom | Cause / fix | |---|---| | Failure mail: `HDD 'BACKUP' not attached` | Unplugged or USB dropped it. Replug; `lsblk`. | | Run hangs, journal full of `input/output error` retries | Backup drive pulled mid-run. `sudo systemctl stop gitea-backup` (Ctrl+C alone does not stop it; the stop counts as a failure — mail sent), replug, then [ntfs-repair.md](ntfs-repair.md). | | Failure mail / error: `BACKUP is dirty` | Power cut, unsafe eject or pull while mounted. Triage in [ntfs-repair.md](ntfs-repair.md): flag only → `ntfsfix`; `$MFTMirr` mismatch → `ntfsfix -d`; `Mark volume as dirty due to NTFS errors` → chkdsk VM. | | Failure mail: `another gitea-backup is already running` | A manual run overlapped. Harmless; next night runs. | | No Sunday report mail | Timer not firing, or mail broken. `systemctl list-timers`, `sudo gitea-backup test-mail`, `/var/log/msmtp.log`. | | `repository is already locked by PID … lock was created at …` | A run cut off mid-write left its lock (its release never reached the disk). Every subcommand runs `restic unlock` first, which drops locks of dead processes (not yet exercised on a real stale lock). If it persists and nothing is running: `sudo sh -c '. /etc/gitea-backup/env; export RESTIC_REPOSITORY RESTIC_PASSWORD_FILE; mount -t ntfs3 /dev/disk/by-label/BACKUP /mnt/backup && restic unlock --remove-all; cd /; umount /mnt/backup'`. | | `$MFTMirr does not match $MFT (record 3)` from `ntfsfix -n` | Backup drive pulled while mounted. [ntfs-repair.md](ntfs-repair.md) rung 2. | | `msmtp: 535-5.7.8 Username and Password not accepted` | Wrong secret in `/etc/msmtprc` — see [11](11-backup-automated.md) step 5 (length must be 16). | | `hostname: command not found` | Old script — minimal Arch has no `hostname`; current script uses `uname -n`. Reinstall ([11](11-backup-automated.md) step 3). | | `daemon-reload: command not found` | It is `sudo systemctl daemon-reload`. | | Gitea down after a failure | The EXIT trap restarts it; if that also failed the mail says so — `docker start gitea`. |