feat: configure shinkan-prod-db on llm-node and disable on raspberrypi5
This commit is contained in:
1 parent
feb469d47b
commit
03e09fd0d0
8 files changed
+66
-29
No files matched your search
@@ -125,3 +125,4 @@ Bitte setze folgende Anforderungen um und verändere keine Produktionsdaten auf
|
|||||||
- Prüfe mit `curl -s -i http://127.0.0.1:<PORT>/api/health/ready`, dass der Readiness-Check grün meldet.
|
- Prüfe mit `curl -s -i http://127.0.0.1:<PORT>/api/health/ready`, dass der Readiness-Check grün meldet.
|
||||||
- Melde zurück: DB-Engine, Containername, DB-Name, DB-User, Health-URL, Session-Tabelle und nicht-leere Kern-Tabellen.
|
- Melde zurück: DB-Engine, Containername, DB-Name, DB-User, Health-URL, Session-Tabelle und nicht-leere Kern-Tabellen.
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -105,3 +105,4 @@ In Uptime Kuma wechselt der Monitor sofort auf **"UP"** (grün) und zeigt im Ere
|
|||||||
- **Entkopplung**: Push-Benachrichtigungen werden asynchron über einen Thread-Pool versendet.
|
- **Entkopplung**: Push-Benachrichtigungen werden asynchron über einen Thread-Pool versendet.
|
||||||
- **Sicherheitsgarantie**: Netzwerk-Timeouts oder Fehler von Uptime Kuma verändern **niemals** den Exit-Code des Backup-Laufs. Ein erfolgreiches Backup bleibt immer `Exit 0`.
|
- **Sicherheitsgarantie**: Netzwerk-Timeouts oder Fehler von Uptime Kuma verändern **niemals** den Exit-Code des Backup-Laufs. Ein erfolgreiches Backup bleibt immer `Exit 0`.
|
||||||
- Fehlerhafte Push-Versuche werden in `/var/log/backup-orchestrator/<run_id>/notifications.log` protokolliert.
|
- Fehlerhafte Push-Versuche werden in `/var/log/backup-orchestrator/<run_id>/notifications.log` protokolliert.
|
||||||
|
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
"nas_mount": "/mnt/nas_backup",
|
"nas_mount": "/mnt/nas_backup",
|
||||||
"nas_source": "192.168.2.63:/volume1/Backup_LLM",
|
"nas_source": "192.168.2.63:/volume1/Backup_LLM",
|
||||||
"nas_fstype": "nfs",
|
"nas_fstype": "nfs",
|
||||||
"local_dump_dir": "/mnt/nas_backup/shinkan/prod/db/latest",
|
"local_dump_dir": "/mnt/nas_backup/recovery_points/shinkan-prod/latest",
|
||||||
"archive_sets_dir": "/mnt/nas_backup/shinkan/prod/db",
|
"archive_sets_dir": "/mnt/nas_backup/recovery_points",
|
||||||
"media_mounts": {
|
"media_mounts": {
|
||||||
"shinkan-prod": "/srv/shinkan/prod/media"
|
"shinkan-prod": "/srv/shinkan/prod/media"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
phase,id,script,critical,timeout_seconds,enabled
|
phase,id,script,critical,timeout_seconds,enabled
|
||||||
10,shinkan-prod-db,/etc/backup-orchestrator/scripts/db-shinkan-prod.sh,true,900,false
|
10,shinkan-prod-db,/etc/backup-orchestrator/scripts/db-shinkan-prod.sh,true,900,true
|
||||||
|
@@ -1,33 +1,66 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Backup wrapper for Shinkan Production on llm-node (post-cutover)
|
# ============================================================================
|
||||||
|
# Backup wrapper for Shinkan Production on llm-node (Ubuntu 24.04 x86_64)
|
||||||
|
# Captures PostgreSQL dump, creates schema manifest & sha256, and publishes
|
||||||
|
# atomic backup set to NAS recovery_points.
|
||||||
|
# ============================================================================
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
umask 027
|
||||||
|
|
||||||
DEST_ROOT="/mnt/nas_backup/shinkan/prod/db"
|
ARCHIVE_ROOT="/mnt/nas_backup/recovery_points"
|
||||||
TS="$(date -u +%Y%m%dT%H%M%SZ)"
|
TARGET_ID="shinkan-prod"
|
||||||
GEN_DIR="${DEST_ROOT}/generations/${TS}"
|
DB_CONTAINER="shinkan-db-prod"
|
||||||
DUMP_FILE="${GEN_DIR}/shinkan-prod.sql"
|
DB_NAME="shinkan"
|
||||||
|
DB_USER="shinkan_user"
|
||||||
|
|
||||||
install -d -m 0750 "${GEN_DIR}"
|
# Verify NAS mount
|
||||||
|
if ! mountpoint -q /mnt/nas_backup; then
|
||||||
|
echo "FEHLER: /mnt/nas_backup ist nicht gemountet!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
export DB_CONTAINER="shinkan-db-prod"
|
TMP_DIR="$(mktemp -d /tmp/shinkan-backup.XXXXXXXX)"
|
||||||
export DB_USER="shinkan"
|
cleanup() {
|
||||||
export DB_NAME="shinkan"
|
rm -rf -- "$TMP_DIR"
|
||||||
export OUTPUT_PATH="${DUMP_FILE}"
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
/etc/backup-orchestrator/scripts/db-postgres-docker.sh
|
DUMP_FILE="${TMP_DIR}/shinkan-prod.sql"
|
||||||
|
RESULT_FILE="${TMP_DIR}/manifest-result.json"
|
||||||
|
|
||||||
# Generate SHA256, Manifest (schemaVersion: 1), and Media Inventory (.media.jsonl)
|
echo "1. Erstelle PostgreSQL-Dump fuer ${DB_CONTAINER} (${DB_NAME})..."
|
||||||
/etc/backup-orchestrator/scripts/shinkan/shinkan-backup-manifest \
|
docker exec "${DB_CONTAINER}" sh -ec '
|
||||||
--dump "${DUMP_FILE}" \
|
export PGPASSWORD="${POSTGRES_PASSWORD:-}"
|
||||||
--env prod \
|
exec pg_dump -U "'"${DB_USER}"'" "'"${DB_NAME}"'"
|
||||||
--host "llm-node" \
|
' > "${DUMP_FILE}"
|
||||||
--compose-dir "/home/llmadmin/docker/shinkan-prod" \
|
|
||||||
--media-dir "/srv/shinkan/prod/media" \
|
|
||||||
--db-container "shinkan-db-prod" \
|
|
||||||
--db-name "shinkan" \
|
|
||||||
--db-user "shinkan"
|
|
||||||
|
|
||||||
# Atomically update 'latest' symlink after complete backup set verification
|
if [[ ! -s "${DUMP_FILE}" ]]; then
|
||||||
ln -sfn "generations/${TS}" "${DEST_ROOT}/latest.tmp.$$"
|
echo "FEHLER: Dump ist leer!" >&2
|
||||||
mv -Tf "${DEST_ROOT}/latest.tmp.$$" "${DEST_ROOT}/latest"
|
exit 1
|
||||||
echo "Published atomic Shinkan backup set on llm-node: ${GEN_DIR}"
|
fi
|
||||||
|
chmod 0640 "${DUMP_FILE}"
|
||||||
|
|
||||||
|
echo "2. Erstelle Manifest, SHA256 und Medien-Index..."
|
||||||
|
MANIFEST_SCRIPT="/etc/backup-orchestrator/scripts/shinkan/shinkan-backup-manifest"
|
||||||
|
if [[ ! -f "$MANIFEST_SCRIPT" ]]; then
|
||||||
|
MANIFEST_SCRIPT="$(dirname "${BASH_SOURCE[0]}")/../../scripts/shinkan/shinkan-backup-manifest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
python3 "${MANIFEST_SCRIPT}" \
|
||||||
|
--target "llm-prod" \
|
||||||
|
--dump "${DUMP_FILE}" \
|
||||||
|
--out-dir "${TMP_DIR}" \
|
||||||
|
--result "${RESULT_FILE}"
|
||||||
|
|
||||||
|
echo "3. Veroeffentliche Backup-Set im Recovery-Archiv..."
|
||||||
|
PUBLISH_SCRIPT="/etc/backup-orchestrator/scripts/publish-backup-set.sh"
|
||||||
|
if [[ ! -f "$PUBLISH_SCRIPT" ]]; then
|
||||||
|
PUBLISH_SCRIPT="$(dirname "${BASH_SOURCE[0]}")/../../scripts/common/publish-backup-set.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash "${PUBLISH_SCRIPT}" \
|
||||||
|
"${TARGET_ID}" \
|
||||||
|
"${DUMP_FILE}" \
|
||||||
|
"${ARCHIVE_ROOT}"
|
||||||
|
|
||||||
|
echo "OK: Shinkan Production Backup auf llm-node erfolgreich abgeschlossen."
|
||||||
@@ -3,7 +3,7 @@ phase,id,script,critical,timeout_seconds,enabled
|
|||||||
10,tandoor-db,/etc/backup-orchestrator/scripts/db-tandoor.sh,true,600,true
|
10,tandoor-db,/etc/backup-orchestrator/scripts/db-tandoor.sh,true,600,true
|
||||||
10,mitai-prod-db,/etc/backup-orchestrator/scripts/db-mitai-prod.sh,true,900,true
|
10,mitai-prod-db,/etc/backup-orchestrator/scripts/db-mitai-prod.sh,true,900,true
|
||||||
10,mitai-dev-db,/etc/backup-orchestrator/scripts/db-mitai-dev.sh,false,900,true
|
10,mitai-dev-db,/etc/backup-orchestrator/scripts/db-mitai-dev.sh,false,900,true
|
||||||
10,shinkan-prod-db,/etc/backup-orchestrator/scripts/db-shinkan-prod.sh,true,600,true
|
10,shinkan-prod-db,/etc/backup-orchestrator/scripts/db-shinkan-prod.sh,true,600,false
|
||||||
10,shinkan-dev-db,/etc/backup-orchestrator/scripts/db-shinkan-dev.sh,false,600,true
|
10,shinkan-dev-db,/etc/backup-orchestrator/scripts/db-shinkan-dev.sh,false,600,true
|
||||||
20,nas-data,/etc/backup-orchestrator/scripts/nas-data-job.sh,true,10800,true
|
20,nas-data,/etc/backup-orchestrator/scripts/nas-data-job.sh,true,10800,true
|
||||||
30,system-image,/etc/backup-orchestrator/scripts/system-image-job.sh,true,14400,false
|
30,system-image,/etc/backup-orchestrator/scripts/system-image-job.sh,true,14400,false
|
||||||
|
|||||||
|
@@ -533,3 +533,4 @@ def main():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
||||||
@@ -125,3 +125,4 @@ class UniversalDbRestoreTests(unittest.TestCase):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
Reference in new issue
Block a user