Files
nixos-config/servers/hetzner/modules/services/backup.nix
T
jory ff31b21a74
CI / Flake check (aarch64-linux) (push) Successful in 32s
CI / Flake check (x86_64-linux) (push) Successful in 32s
CI / Pre-commit checks (x86_64-linux) (push) Successful in 10s
Harden server and add Nix-native CI + self-hosted Gitea Actions
- Add self-hosted Gitea Actions runner module (servers/hetzner/modules/services/gitea.nix)
- Add CI workflow (.gitea/workflows/ci.yml):
  - Flake check (x86_64-linux + aarch64-linux, eval-only)
  - Pre-commit checks (x86_64-linux only)
  - Gitea-native runner (no Docker); Nix from host PATH
  - NIX_CONFIG enables flakes + extra-platforms
- Remove redundant .github/workflows/ci.yml (shadows .gitea)
- Enable deadnix in pre-commit hooks (flake.nix), fix 38 files
- Add statix.toml disabling empty_pattern lint (nixpkgs standard)
- Format whole repo with alejandra (27 files)
- Fix CI nix-not-found: export /run/current-system/sw/bin in PATH
- Remove aarch64 from pre-commit matrix (no QEMU binfmt deployed yet)
2026-07-12 08:24:14 +02:00

42 lines
1.2 KiB
Nix

{pkgs, ...}: let
backupScript = pkgs.writeShellScript "weekly-backup" ''
BACKUP_DIR="/home/admin/backups"
SRC="/home/admin"
DATE=$(date +%Y-%m-%dT%H-%M-%S)
FILENAME="weekly-backup-$DATE.tar.gz"
mkdir -p "$BACKUP_DIR"
# Backup everything under /home/admin EXCEPT:
# - The backups dir itself (infinite loop)
# - DMS mail data (GBs of email, backed up separately)
# - NixOS-managed service data (at their own paths below)
tar czf "$BACKUP_DIR/$FILENAME" \
--exclude="$BACKUP_DIR" \
--exclude="/home/admin/backups" \
--exclude="/home/admin/dms/mail-data" \
--exclude="/home/admin/dms/mail-state" \
"$SRC"
# Prune backups older than 14 days
find "$BACKUP_DIR" -name "weekly-backup-*" -mtime +14 -delete
'';
in {
systemd.services.weekly-backup = {
description = "Weekly backup of home directory";
path = with pkgs; [coreutils gnutar findutils];
serviceConfig = {
Type = "oneshot";
ExecStart = "${backupScript}";
User = "root";
};
};
systemd.timers.weekly-backup = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "Mon *-*-* 03:00:00";
Persistent = true;
};
};
}