fix: address review feedback on backup improvements
- manifests/gitea/dump-cronjob.yaml: Remove --skip-log, --skip-custom-dir, --skip-db flags to make backup complete - manifests/gitea/dump-cronjob.yaml: Replace NFS volume + cleanup container with S3 upload to backup-gitea bucket using MinIO client (mc). 30-day lifecycle set via mc ilm. Uses minio_key/minio_secret from existing gitea-config secret. - hosts/unstable/hosea/default.nix: Replace raw services.restic.backups.albyhub block with greg.backup.jobs.albyhub using the greg.backup module. Remove manual age.secrets.restic-env and age.secrets.restic-pw entries since the greg.backup module declares them.
This commit is contained in:
@@ -60,6 +60,12 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
tags = [ "home" ];
|
tags = [ "home" ];
|
||||||
};
|
};
|
||||||
|
backup.jobs.albyhub = {
|
||||||
|
src = "/chain/alby";
|
||||||
|
dest = "albyhub";
|
||||||
|
pre = "systemctl stop albyhub || true";
|
||||||
|
post = "systemctl start albyhub";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware = {
|
hardware = {
|
||||||
@@ -145,24 +151,6 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
prometheus.exporters.graphite.enable = true;
|
prometheus.exporters.graphite.enable = true;
|
||||||
restic.backups.albyhub = {
|
|
||||||
# AlbyHub LDK node data — must not be snapshotted live
|
|
||||||
paths = [ "/chain/alby" ];
|
|
||||||
environmentFile = config.age.secrets.restic-env.path;
|
|
||||||
passwordFile = config.age.secrets.restic-pw.path;
|
|
||||||
initialize = true;
|
|
||||||
pruneOpts = [
|
|
||||||
"--keep-daily 7"
|
|
||||||
"--keep-weekly 4"
|
|
||||||
"--keep-monthly 12"
|
|
||||||
];
|
|
||||||
backupPrepareCommand = "systemctl stop albyhub || true";
|
|
||||||
backupCleanupCommand = "systemctl start albyhub";
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = "02:30";
|
|
||||||
RandomizedDelaySec = "30min";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# Configure keymap
|
# Configure keymap
|
||||||
xserver.xkb = {
|
xserver.xkb = {
|
||||||
layout = "us";
|
layout = "us";
|
||||||
@@ -176,12 +164,6 @@ in
|
|||||||
file = ../../../secrets/grafana-api-token.age;
|
file = ../../../secrets/grafana-api-token.age;
|
||||||
owner = "grafana";
|
owner = "grafana";
|
||||||
};
|
};
|
||||||
age.secrets.restic-pw = {
|
|
||||||
file = ../../../secrets/restic-pw.age;
|
|
||||||
};
|
|
||||||
age.secrets.restic-env = {
|
|
||||||
file = ../../../secrets/restic-env.age;
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.etc = {
|
environment.etc = {
|
||||||
"grafana-dashboards/system-health.json".text = ''
|
"grafana-dashboards/system-health.json".text = ''
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ spec:
|
|||||||
- name: gitea-data
|
- name: gitea-data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: gitea-shared-storage
|
claimName: gitea-shared-storage
|
||||||
- name: dump-output
|
- name: dump-staging
|
||||||
nfs:
|
emptyDir: {}
|
||||||
path: /mnt/all/backups/gitea-dumps
|
|
||||||
server: nas1.shire-zebra.ts.net
|
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: gitea-dump
|
- name: gitea-dump
|
||||||
image: "gitea/gitea:1.25.4"
|
image: "gitea/gitea:1.25.4"
|
||||||
@@ -32,30 +30,47 @@ spec:
|
|||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||||
OUTFILE="/dump-output/gitea-dump-${TIMESTAMP}.zip"
|
OUTFILE="/dump-staging/gitea-dump-${TIMESTAMP}.zip"
|
||||||
gitea dump \
|
gitea dump \
|
||||||
--config /data/gitea/conf/app.ini \
|
--config /data/gitea/conf/app.ini \
|
||||||
--file "${OUTFILE}" \
|
--file "${OUTFILE}" \
|
||||||
--type zip \
|
--type zip
|
||||||
--skip-log \
|
|
||||||
--skip-custom-dir \
|
|
||||||
--skip-db
|
|
||||||
echo "Dump written to ${OUTFILE}"
|
echo "Dump written to ${OUTFILE}"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: gitea-data
|
- name: gitea-data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: dump-output
|
- name: dump-staging
|
||||||
mountPath: /dump-output
|
mountPath: /dump-staging
|
||||||
containers:
|
containers:
|
||||||
- name: cleanup
|
- name: upload-to-s3
|
||||||
image: "busybox:1.36"
|
image: "minio/mc:latest"
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- "-c"
|
- "-c"
|
||||||
- |
|
- |
|
||||||
ls -t /dump-output/gitea-dump-*.zip 2>/dev/null | tail -n +31 | xargs rm -f
|
set -e
|
||||||
echo "Cleanup done."
|
# Configure mc alias for MinIO
|
||||||
|
mc alias set nas1 http://nas1.shire-zebra.ts.net:9000 \
|
||||||
|
"${MINIO_ACCESS_KEY}" "${MINIO_SECRET_KEY}"
|
||||||
|
# Upload dump to backup-gitea bucket
|
||||||
|
DUMP_FILE=$(ls /dump-staging/gitea-dump-*.zip | head -1)
|
||||||
|
mc cp "${DUMP_FILE}" "nas1/backup-gitea/$(basename ${DUMP_FILE})"
|
||||||
|
echo "Uploaded $(basename ${DUMP_FILE}) to backup-gitea"
|
||||||
|
# Set 30-day lifecycle on the bucket (idempotent)
|
||||||
|
mc ilm rule add --expire-days 30 nas1/backup-gitea 2>/dev/null || true
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: dump-output
|
- name: dump-staging
|
||||||
mountPath: /dump-output
|
mountPath: /dump-staging
|
||||||
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: MINIO_ACCESS_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gitea-config
|
||||||
|
key: minio_key
|
||||||
|
- name: MINIO_SECRET_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gitea-config
|
||||||
|
key: minio_secret
|
||||||
|
|||||||
Reference in New Issue
Block a user