Tag 15: CNPG: Backups und Wiederherstellung
Ziel:
pg-notesarchiviert WAL und Base-Backups in einen S3-Speicher aufpg2, sichert nachts automatisch, und du stellst einen gelöschten Datenbestand per Point-in-Time-Recovery in einem neuen Cluster wieder her. · Dauer: ca. 75 min · Voraussetzung: Tag 9, Tag 14
Briefing
- CNPG sichert wie Tag 9: Base-Backup plus lückenloses WAL-Archiv – nur in einen Objektspeicher (S3, Azure, GCS) statt auf eine Platte.
- Seit CNPG 1.26 erledigt das das Barman-Cloud-Plugin
(CNPG-I); das eingebaute
barmanObjectStoreist veraltet und fällt mit 1.32 weg. Plugin braucht cert-manager (Tag 14). - Wiederhergestellt wird immer in einen neuen Cluster
(
bootstrap.recovery). - Ziel liegt außerhalb des Clusters: Ein Backup im selben Cluster ist kein Backup.
ost / tag14 pg2 (172.16.0.123)
pg-notes-1..3 [postgres | plugin-barman-cloud] --S3--> RustFS :9000
^ bucket cnpg-backups
cnpg-system: barman-cloud (Plugin) <-- ObjectStore pg2-s3 pg-notes/base/...
pg-notes/wals/...
ost / tag15: pg-notes-pitr <-- bootstrap.recovery ------------'
mkdir -p ~/pg/tag15 && cp ~/.kube/config ~/pg/tag15/.kc
export KUBECONFIG=~/pg/tag15/.kc
kubectl create namespace tag15Drill 1: S3-Speicher auf pg2
Viele Anleitungen nennen MinIO. Die Community-Ausgabe von MinIO ist
aber archiviert: dl.min.io antwortet mit
410 Gone, die Images auf Docker Hub und Quay sind weg. Die
Barman-Cloud-Doku nimmt inzwischen RustFS als Beispiel
– S3-kompatibel, ein Binary, Pakete für amd64 und arm64. Es läuft auf
pg2, also außerhalb von ost.
Auf pg2:
ARCH=$(uname -m)
V=1.0.6
U=https://github.com/rustfs/rustfs/releases/download/$V
cd /tmp
curl -fsSLO $U/rustfs-linux-${ARCH}-gnu-v$V.deb
curl -fsSLO $U/SHA256SUMS
sha256sum --ignore-missing -c SHA256SUMS
sudo apt-get install -y ./rustfs-linux-${ARCH}-gnu-v$V.deb
cd -Erwartet (gekürzt):
rustfs-linux-x86_64-gnu-v1.0.6.deb: OK
...
Setting up rustfs (1.0.6) ...
Die Asset-Namen benutzen x86_64 und aarch64
– genau das, was uname -m liefert. Das Paket bringt
Benutzer rustfs, /data/rustfs und eine
systemd-Unit mit, die ihre Einstellungen aus
/etc/default/rustfs liest:
sudo tee /etc/default/rustfs >/dev/null <<'EOF'
RUSTFS_ACCESS_KEY=pglab
RUSTFS_SECRET_KEY=lab-s3-secret-123
RUSTFS_VOLUMES=/data/rustfs
RUSTFS_ADDRESS=:9000
RUSTFS_CONSOLE_ENABLE=false
EOF
sudo chmod 640 /etc/default/rustfs
sudo systemctl enable --now rustfs
systemctl is-active rustfs
curl -s http://172.16.0.123:9000/health; echoErwartet:
active
{"service":"rustfs-endpoint","status":"ok","timestamp":"2026-11-19T05:10:19...",
"version":"1.0.6"}
Der Bucket muss vorher existieren (siehe Achtung unten). Ein
S3-Client ist nicht nötig: curl signiert Anfragen selbst
mit AWS Signature V4:
S3="--aws-sigv4 aws:amz:us-east-1:s3 --user pglab:lab-s3-secret-123"
curl -s -w '%{http_code}\n' $S3 -X PUT http://172.16.0.123:9000/cnpg-backups
curl -s $S3 http://172.16.0.123:9000/ | grep -o '<Name>[^<]*</Name>'Erwartet:
200
<Name>cnpg-backups</Name>
Achtung: Die Doku sagt, der Bucket entstehe beim ersten Zugriff. Das stimmt nur für ein Base-Backup. Die WAL-Archivierung legt ihn nicht an; ohne Bucket meldet der Sidecar bei jedem WAL
NoSuchBucketundpg_walläuft voll.
Fortschritt speichern? Kostenlos registrieren
Drill 2: Plugin installieren
Zurück auf cp1. Das Plugin muss im Namespace des Operators laufen und braucht CNPG ab 1.30 sowie cert-manager aus Tag 14 (für das mTLS zwischen Operator und Plugin):
kubectl get deployment -n cnpg-system cnpg-controller-manager \
-o jsonpath='{.spec.template.spec.containers[*].image}'; echo
cmctl check api
kubectl apply -f https://github.com/cloudnative-pg/plugin-barman-cloud/\
releases/download/v0.16.0/manifest.yaml
kubectl rollout status deploy/barman-cloud -n cnpg-system
kubectl get pods -n cnpg-systemErwartet (gekürzt):
ghcr.io/cloudnative-pg/cloudnative-pg:1.30.2
The cert-manager API is ready
customresourcedefinition.apiextensions.k8s.io/objectstores.barmancloud.cnpg.io created
...
certificate.cert-manager.io/barman-cloud-client created
certificate.cert-manager.io/barman-cloud-server created
issuer.cert-manager.io/selfsigned-issuer created
deployment "barman-cloud" successfully rolled out
NAME READY STATUS RESTARTS AGE
barman-cloud-5699545794-n66wg 1/1 Running 0 21s
cnpg-controller-manager-6468465f77-4drn5 1/1 Running 0 20m
Plugin-Image und Sidecar-Image
(plugin-barman-cloud-sidecar:v0.16.0) gibt es für amd64 und
arm64. cmctl aus Tag 14; ohne cmctl zeigt
kubectl get pods -n cert-manager, ob cert-manager
läuft.
Fortschritt speichern? Kostenlos registrieren
Drill 3: ObjectStore und WAL-Archivierung
Die Zugangsdaten gehören in ein Secret, das Ziel in die CRD
ObjectStore. Beides liegt im Namespace des Clusters:
kubectl create secret generic s3-creds -n tag14 \
--from-literal=ACCESS_KEY_ID=pglab \
--from-literal=ACCESS_SECRET_KEY=lab-s3-secret-123
cat > ~/pg/tag15/objectstore.yaml <<'EOF'
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: pg2-s3
namespace: tag14
spec:
retentionPolicy: "7d"
configuration:
destinationPath: s3://cnpg-backups/
endpointURL: http://172.16.0.123:9000
s3Credentials:
accessKeyId:
name: s3-creds
key: ACCESS_KEY_ID
secretAccessKey:
name: s3-creds
key: ACCESS_SECRET_KEY
wal:
compression: gzip
data:
compression: gzip
instanceSidecarConfiguration:
resources:
requests: {cpu: 10m, memory: 64Mi}
limits: {memory: 256Mi}
EOF
kubectl apply -f ~/pg/tag15/objectstore.yamlErwartet:
secret/s3-creds created
objectstore.barmancloud.cnpg.io/pg2-s3 created
retentionPolicy löscht Backups und WAL, die älter als 7
Tage sind (Einheiten d, w, m).
Jetzt bekommt der Cluster das Plugin als WAL-Archiver:
kubectl patch cluster pg-notes -n tag14 --type merge -p '{"spec":{"plugins":[
{"name":"barman-cloud.cloudnative-pg.io","isWALArchiver":true,
"parameters":{"barmanObjectName":"pg2-s3"}}]}}'
kubectl get pods -n tag14 -wErwartet (gekürzt, nach etwa zwei Minuten Strg+C):
cluster.postgresql.cnpg.io/pg-notes patched
NAME READY STATUS RESTARTS AGE
pg-notes-3 0/2 Init:1/2 0 19s
pg-notes-3 2/2 Running 0 51s
pg-notes-1 1/2 PodInitializing 0 5s
pg-notes-1 2/2 Running 0 36s
pg-notes-2 0/2 Init:1/2 0 5s
pg-notes-2 2/2 Running 0 36s
Der Operator rollt neu aus: erst die Replicas, zuletzt der Primary.
Jeder Pod hat jetzt zwei Container – der Sidecar
plugin-barman-cloud läuft als nativer
Sidecar-Init-Container (restartPolicy: Always):
kubectl get pod pg-notes-2 -n tag14 -o jsonpath='{range .spec.initContainers[*]}\
{.name} {.restartPolicy}{"\n"}{end}'
kubectl cnpg status pg-notes -n tag14 | sed -n '/Continuous/,/^$/p'Erwartet (gekürzt):
bootstrap-controller
plugin-barman-cloud Always
Continuous Backup status (Barman Cloud Plugin)
No recovery window information found in ObjectStore 'pg2-s3' for server 'pg-notes'
Working WAL archiving: OK
WALs waiting to be archived: 0
Last Archived WAL: 000000020000000000000009 @ 2026-11-19T05:14:33Z
Fehlt der Bucket, steht hier
Working WAL archiving: Failing, und das Sidecar-Log
(kubectl logs pg-notes-2 -n tag14 -c plugin-barman-cloud)
zeigt:
ERROR: Barman cloud WAL archiver exception: An error occurred (NoSuchBucket) when
calling the PutObject operation: The specified bucket does not exist
Fortschritt speichern? Kostenlos registrieren
Drill 4: On-demand-Backup
kubectl cnpg backup pg-notes -n tag14 --backup-name pg-notes-erstes \
--method plugin --plugin-name barman-cloud.cloudnative-pg.io
kubectl get backup -n tag14 -wErwartet (gekürzt, nach etwa 30 s Strg+C):
backup/pg-notes-erstes created
NAME AGE CLUSTER METHOD PHASE ERROR
pg-notes-erstes 5s pg-notes plugin started
pg-notes-erstes 27s pg-notes plugin completed
Das Plugin legt ein Objekt Backup an – genauso gut per
YAML mit method: plugin und
pluginConfiguration.name. Wo lief es?
kubectl get backup pg-notes-erstes -n tag14 -o json | jq -r '.status | .backupId,
.beginWal, .endWal, .instanceID.podName, .online, .phase'Erwartet:
20261119T051518
00000002000000000000000A
00000002000000000000000A
pg-notes-1
true
completed
pg-notes-1 ist eine Replica:
Standard-Ziel ist prefer-standby, der Primary bleibt
entlastet (--backup-target primary erzwingt ihn). Auf
pg2 liegen jetzt Base-Backup und WAL. Auf
pg2 (mit S3 aus Drill 1):
curl -s $S3 "http://172.16.0.123:9000/cnpg-backups?list-type=2&prefix=pg-notes/" \
| grep -oE '<Key>[^<]*</Key>|<Size>[^<]*</Size>' | sed -E 's/<[^>]+>//g' \
| paste - -Erwartet:
pg-notes/base/20261119T051518/backup.info 1431
pg-notes/base/20261119T051518/data.tar.gz 4242802
pg-notes/wals/0000000200000000/000000020000000000000009.gz 16549
Dieselbe Struktur wie barman-cloud-backup aus der
Barman-Welt: base/<ID>/ und
wals/<Timeline+Log>/. Der Ordner heißt nach dem
Cluster (serverName).
Fortschritt speichern? Kostenlos registrieren
Drill 5: Geplante Backups
ScheduledBackup nimmt ein Cron-Format mit
sechs Feldern – das erste sind Sekunden.
immediate: true startet zusätzlich sofort ein Backup:
cat > ~/pg/tag15/scheduled.yaml <<'EOF'
apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
name: pg-notes-nachts
namespace: tag14
spec:
cluster:
name: pg-notes
schedule: "0 0 2 * * *"
immediate: true
backupOwnerReference: self
method: plugin
pluginConfiguration:
name: barman-cloud.cloudnative-pg.io
EOF
kubectl apply -f ~/pg/tag15/scheduled.yaml
kubectl get scheduledbackup,backup -n tag14
kubectl get scheduledbackup pg-notes-nachts -n tag14 \
-o jsonpath='{.status.nextScheduleTime}{"\n"}'Erwartet (gekürzt, nach etwa 40 s):
scheduledbackup.postgresql.cnpg.io/pg-notes-nachts created
NAME AGE CLUSTER LAST BACKUP
scheduledbackup.postgresql.cnpg.io/pg-notes-nachts 41s pg-notes 41s
NAME ... PHASE
backup.postgresql.cnpg.io/pg-notes-erstes ... completed
backup.postgresql.cnpg.io/pg-notes-nachts-20261119051605 ... completed
2026-11-20T02:00:00Z
backupOwnerReference: self hängt die erzeugten
Backup-Objekte an den ScheduledBackup: Löschst
du ihn, verschwinden die Objekte – die Dateien im Bucket nicht, die
räumt nur retentionPolicy ab. Der Status steht auch im
Cluster:
kubectl cnpg status pg-notes -n tag14 | sed -n '/Continuous/,/^$/p'Erwartet (gekürzt):
Continuous Backup status (Barman Cloud Plugin)
ObjectStore / Server name: pg2-s3/pg-notes
First Point of Recoverability: 2026-11-19 05:15:33 UTC
Last Successful Backup: 2026-11-19 ...
Last Failed Backup: -
Working WAL archiving: OK
Tipp: Volume-Snapshots (
method: volumeSnapshot) sind bei großen Datenbanken schneller, brauchen aber einen CSI-Treiber mit Snapshot-Unterstützung.local-pathkann das nicht:kubectl get volumesnapshotclassmeldet hierthe server doesn't have a resource type.
Fortschritt speichern? Kostenlos registrieren
Drill 6: Unfall und Point-in-Time-Recovery
Eine Tabelle entsteht, du merkst dir die Zeit – und dann geht sie verloren:
kubectl cnpg psql pg-notes -n tag14 -- -d notes \
-c "CREATE TABLE kunden (id int PRIMARY KEY, name text)" \
-c "INSERT INTO kunden SELECT i, 'Kunde ' || i FROM generate_series(1,500) i"
kubectl cnpg psql pg-notes -n tag14 -- -d notes \
-Atc 'SELECT count(*), now() FROM kunden'
kubectl cnpg psql pg-notes -n tag14 -- -d notes -c 'DROP TABLE kunden' \
-c 'SELECT pg_switch_wal()'Erwartet (gekürzt):
CREATE TABLE
INSERT 0 500
500|2026-11-19 05:17:04.88945+00
DROP TABLE
pg_switch_wal
---------------
0/A041BD0
pg_switch_wal() schließt das WAL-Segment ab, damit der
DROP sofort im Archiv liegt – sonst greift erst
archive_timeout (bei CNPG 5 min). Wiederhergestellt wird in
tag15. Ein ObjectStore wirkt nur in seinem
Namespace, deshalb dort eine Kopie:
kubectl create secret generic s3-creds -n tag15 \
--from-literal=ACCESS_KEY_ID=pglab \
--from-literal=ACCESS_SECRET_KEY=lab-s3-secret-123
sed 's/namespace: tag14/namespace: tag15/' ~/pg/tag15/objectstore.yaml \
| kubectl apply -f -
cat > ~/pg/tag15/pitr.yaml <<'EOF'
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-notes-pitr
namespace: tag15
spec:
instances: 1
imageName: ghcr.io/cloudnative-pg/postgresql:18.7-minimal-trixie
storage:
size: 1Gi
resources:
requests: {cpu: 50m, memory: 128Mi}
limits: {memory: 256Mi}
bootstrap:
recovery:
source: pg-notes-backup
recoveryTarget:
targetTime: "2026-11-19 05:17:04.88945+00"
externalClusters:
- name: pg-notes-backup
plugin:
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: pg2-s3
serverName: pg-notes
EOF
kubectl apply -f ~/pg/tag15/pitr.yaml
kubectl get pods -n tag15 -wTrage bei targetTime deine Zeit von oben ein.
Erwartet (gekürzt, nach etwa 90 s Strg+C):
cluster.postgresql.cnpg.io/pg-notes-pitr created
NAME READY STATUS RESTARTS AGE
pg-notes-pitr-1-full-recovery-tw4nc 0/2 Init:1/2 0 7s
pg-notes-pitr-1-full-recovery-tw4nc 2/2 Running 0 9s
pg-notes-pitr-1-full-recovery-tw4nc 0/2 Completed 0 41s
pg-notes-pitr-1 2/2 Running 0 12s
pg-notes-pitr-1 2/2 Terminating 0 12s
pg-notes-pitr-1 0/1 Pending 0 0s
pg-notes-pitr-1 1/1 Running 0 12s
Der Job full-recovery holt das Base-Backup, spielt WAL
bis zum Zeitpunkt ein und befördert. Das Plugin wählt selbst das
passende Backup vor targetTime. Danach startet die Instanz
einmal mit Sidecar und wird dann ohne neu angelegt (1/1):
Der Klon hat kein spec.plugins. Kontrolle:
kubectl cnpg psql pg-notes-pitr -n tag15 -- -d notes \
-Atc 'SELECT count(*) FROM kunden' -c 'SELECT count(*) FROM notes'
kubectl cnpg status pg-notes-pitr -n tag15 | grep -E 'System ID|Timeline'
kubectl cnpg status pg-notes -n tag14 | grep -E 'System ID|Timeline'Erwartet (gekürzt):
500
1001
System ID: 7709740788768088084
Current Write LSN: 0/D009558 (Timeline: 3 - WAL File: 00000003000000000000000D)
System ID: 7709740788768088084
Current Write LSN: 0/D000000 (Timeline: 2 - WAL File: 00000002000000000000000D)
Die 500 Kunden sind zurück. Gleiche System ID, aber neue Timeline 3 –
derselbe Mechanismus wie an Tag 9. Die Daten holst du per
pg_dump -t kunden aus dem Klon zurück in
pg-notes, statt den Produktions-Cluster zu ersetzen.
Achtung: Der Klon archiviert selbst nicht (kein
spec.plugins). Soll er das, braucht er einen anderenserverNameoder Bucket – sonst überschreibt er das Archiv vonpg-notes. CNPG prüft das: Der Cluster hängt inSetting up primary, das Log meldetWAL archive check failed ... Expected empty archive.
Fortschritt speichern? Kostenlos registrieren
Drill 7: Klon aufräumen
kubectl delete cluster pg-notes-pitr -n tag15
kubectl get pvc -n tag15Erwartet (gekürzt):
cluster.postgresql.cnpg.io "pg-notes-pitr" deleted from tag15 namespace
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
pg-notes-pitr-1 Terminating pvc-ba122d28-… 1Gi RWO local-path
Mit dem Cluster verschwinden Pods, PVCs (nach wenigen Sekunden) und
Secrets. Bucket und ObjectStore in tag15
bleiben für die Challenge.
Fortschritt speichern? Kostenlos registrieren
Übung: Speed-Drills
- Zeige alle Backups von
pg-notesmit Phase und Instanz, auf der sie liefen. Zeitziel: 30 s - Zeige, ob die WAL-Archivierung gerade funktioniert. Zeitziel: 15 s
- Starte ein Backup, das garantiert auf dem Primary läuft. Zeitziel: 45 s
- Pausiere den nächtlichen Backup-Plan, ohne ihn zu löschen. Zeitziel: 30 s
Lösung
kubectl get backup -n tag14 -o custom-columns=NAME:.metadata.name,\
PHASE:.status.phase,POD:.status.instanceID.podName
kubectl get cluster pg-notes -n tag14 -o jsonpath='{range .status.conditions[*]}\
{.type}={.status}{"\n"}{end}' | grep Archiving
kubectl cnpg backup pg-notes -n tag14 --backup-target primary \
--method plugin --plugin-name barman-cloud.cloudnative-pg.io
kubectl patch scheduledbackup pg-notes-nachts -n tag14 --type merge \
-p '{"spec":{"suspend":true}}'Erwartet (gekürzt):
NAME PHASE POD
pg-notes-erstes completed pg-notes-1
pg-notes-nachts-20261119051605 completed pg-notes-1
ContinuousArchiving=True
backup/pg-notes-20261119052648 created
scheduledbackup.postgresql.cnpg.io/pg-notes-nachts patched
Das Backup mit --backup-target primary lief auf
pg-notes-2, dem Primary (kubectl get backup
nach etwa 20 s).
Danach suspend wieder auf false setzen –
der Plan bleibt für die folgenden Tage:
kubectl patch scheduledbackup pg-notes-nachts -n tag14 --type merge \
-p '{"spec":{"suspend":false}}'Fortschritt speichern? Kostenlos registrieren
Kontrollpunkt
Plugin, RustFS auf pg2, ObjectStore pg2-s3,
die Archivierung von pg-notes und
ScheduledBackup pg-notes-nachts bleiben für Tag 16 bis 19
und die Abschlussprüfung.
kubectl get deploy -n cnpg-system barman-cloudErwartet: 1/1 bereit.
kubectl get objectstore,scheduledbackup -n tag14Erwartet: objectstore.../pg2-s3 und
scheduledbackup.../pg-notes-nachts.
kubectl get scheduledbackup pg-notes-nachts -n tag14 -o jsonpath='{.spec.suspend}'Erwartet: false.
kubectl cnpg status pg-notes -n tag14 | grep -E 'Working WAL|Last Successful'Erwartet: Working WAL archiving: OK und
ein Zeitpunkt von heute.
kubectl get backup -n tag14Erwartet: mindestens zwei Backups mit Phase
completed.
Von deinem Rechner aus:
ssh [email protected] systemctl is-active rustfsErwartet: active.
Challenge
Lege in pg-notes eine Tabelle preise mit
zwei Zeilen an, setze den Restore-Point vor-preisupdate,
setze alle Preise auf 0 und stelle in tag15 einen Cluster
pg-notes-rp genau auf den Restore-Point wieder her.
Hinweis: pg_create_restore_point() und
recoveryTarget.targetName – und lies die Fehlermeldung des
Webhooks genau.
Lösung
kubectl cnpg psql pg-notes -n tag14 -- -d notes \
-c "CREATE TABLE preise (artikel text, preis numeric)" \
-c "INSERT INTO preise VALUES ('Kaffee', 3.50), ('Tee', 2.80)" \
-c "SELECT pg_create_restore_point('vor-preisupdate')" \
-c 'UPDATE preise SET preis = 0' -c 'SELECT pg_switch_wal()'
sed -e 's/name: pg-notes-pitr/name: pg-notes-rp/' \
-e 's/targetTime: .*/targetName: vor-preisupdate/' \
~/pg/tag15/pitr.yaml > ~/pg/tag15/rp.yaml
kubectl apply -f ~/pg/tag15/rp.yamlErwartet (gekürzt):
...
UPDATE 2
The Cluster "pg-notes-rp" is invalid: spec.bootstrap.recovery.recoveryTarget:
Required value: BackupID is missing
Bei targetName, targetXID und
targetImmediate kann CNPG nicht selbst entscheiden, welches
Base-Backup vor dem Ziel liegt – du nennst es mit backupID
(bei targetTime und targetLSN sucht der
Operator selbst):
kubectl get backup -n tag14 -o custom-columns=NAME:.metadata.name,\
ID:.status.backupId,STOP:.status.stoppedAt
ID=$(kubectl get backup pg-notes-nachts-20261119051605 -n tag14 \
-o jsonpath='{.status.backupId}')
sed -i "s/targetName: vor-preisupdate/&\n backupID: $ID/" ~/pg/tag15/rp.yaml
kubectl apply -f ~/pg/tag15/rp.yaml
kubectl get cluster -n tag15
kubectl cnpg psql pg-notes-rp -n tag15 -- -d notes -Atc 'TABLE preise'Erwartet (gekürzt, get cluster nach
etwa 90 s):
NAME ID STOP
pg-notes-erstes 20261119T051518 2026-11-19T05:15:33Z
pg-notes-nachts-20261119051605 20261119T051608 2026-11-19T05:16:15Z
cluster.postgresql.cnpg.io/pg-notes-rp created
NAME AGE INSTANCES READY STATUS PRIMARY
pg-notes-rp 91s 1 1 Cluster in healthy state pg-notes-rp-1
Kaffee|3.50
Tee|2.80
Setze den Namen deines eigenen nächtlichen Backups ein.
Fortschritt speichern? Kostenlos registrieren
Aufräumen
kubectl delete cluster pg-notes-rp -n tag15
kubectl cnpg psql pg-notes -n tag14 -- -d notes -c 'DROP TABLE preise'
kubectl delete namespace tag15Erwartet:
cluster.postgresql.cnpg.io "pg-notes-rp" deleted from tag15 namespace
DROP TABLE
namespace "tag15" deleted
Interview-Notiz
- „Wie sichert CNPG?“ – Seit 1.26 über das Barman-Cloud-Plugin:
Sidecar je Instanz, WAL kontinuierlich und Base-Backups (meist von einer
Replica) in einen Objektspeicher; Ziel als
ObjectStore, Plan alsScheduledBackup. - „Wie stellst du wieder her?“ – Immer in einen neuen Cluster mit
bootstrap.recoveryundexternalClusters; PITR pertargetTime/targetLSN, beitargetName/targetXIDzusätzlichbackupID. - „Was prüfst du täglich?“ –
ContinuousArchiving=True, letztes erfolgreiches Backup, Abstand des First Point of Recoverability – und regelmäßig einen echten Restore.
Enterprise-Notiz
- Bucket in anderer Region oder beim anderen Anbieter, mit Object Lock/Versionierung gegen Ransomware; Zugang mit eigenem Schlüssel pro Cluster, nur Schreibrechte auf den eigenen Präfix.
- Auf AWS/GKE/AKS keine statischen Schlüssel: IRSA, Workload Identity
oder Azure Managed Identity im
ObjectStore. - TLS zum Objektspeicher (
endpointCAbei eigener CA), serverseitige Verschlüsselung (wal.encryption/data.encryptionfür SSE-S3/SSE-KMS oder SSE-C übers3Credentials.sseCustomerKey), Kompressionzstdspart Platz. - Große Datenbanken: Volume-Snapshots (CSI) für schnelle Restores, WAL trotzdem ins Objekt-Archiv; Restore-Tests automatisiert, z. B. wöchentlich ein Klon-Cluster.
- Alarm auf
cnpg_collector_pg_wal_archive_statusund auf das Alter des letzten Backups (Tag 17).