Reapply "feat: add backups for postgres"

This reverts commit d5d242601f.
This commit is contained in:
2025-09-06 20:49:22 +05:00
parent 1b6e98f626
commit 12466975f4
4 changed files with 88 additions and 6 deletions

View File

@@ -35,7 +35,7 @@ export class PostgresCluster extends Construct {
namespace: options.namespace,
});
const destinationPath = "s3://rihla-backups/";
const destinationPath = "s3://homelab-backups/";
const endpointURL = options.backupR2EndpointURL;
const barmanConfiguration = {
@@ -321,7 +321,7 @@ export class PostgresCluster extends Construct {
},
spec: {
instances: 3,
maxSyncReplicas: 0,
maxSyncReplicas: 1,
primaryUpdateStrategy: "unsupervised",
certificates: {
serverCASecret: certNames.server,
@@ -346,12 +346,47 @@ export class PostgresCluster extends Construct {
],
enableSuperuserAccess: false,
bootstrap: {
initdb: {
recovery: {
source: "clusterBackup",
database: "postgres",
owner: options.primaryUser,
secret: {
name: options.initSecretName,
},
postInitSQL: [`CREATE USER ${options.primaryUser} SUPERUSER;`],
},
},
externalClusters: [
{
name: "clusterBackup",
plugin: {
name: "barman-cloud.cloudnative-pg.io",
parameters: {
barmanObjectName: "r2-postgres-backup-store",
serverName: "postgres-cluster",
},
},
},
],
managed: {
services: {
disabledDefaultServices: ["ro", "r"],
additional: [
{
selectorType: "rw",
serviceTemplate: {
metadata: {
name: "postgres-cluster",
annotations: {
"external-dns.alpha.kubernetes.io/hostname":
"postgres.dogar.dev",
},
},
spec: {
type: "LoadBalancer",
},
},
},
],
},
},
storage: {