Skip to content

Commit

Permalink
Add PostgreSQL backup/restore process by using KubeStash (#670)
Browse files Browse the repository at this point in the history
* Add logical backup/restore process for PG

Signed-off-by: Anisur Rahman <[email protected]>

* Incorporate with review changes

Signed-off-by: Anisur Rahman <[email protected]>

* Resolve saiem bhai's review changes

Signed-off-by: Anisur Rahman <[email protected]>

* update deps

Signed-off-by: Anisur Rahman <[email protected]>

* update deps

Signed-off-by: Anisur Rahman <[email protected]>

---------

Signed-off-by: Anisur Rahman <[email protected]>
  • Loading branch information
anisurrahman75 authored Sep 24, 2024
1 parent 6272f9b commit 707e73e
Show file tree
Hide file tree
Showing 85 changed files with 3,784 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
namespace: demo
spec:
manifestOptions:
restoreNamespace: dev
mongoDB:
db: true
restoreNamespace: dev
dataSource:
repository: s3-mongodb-repo
snapshot: latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ metadata:
namespace: demo
spec:
manifestOptions:
restoreNamespace: dev
mongoDB:
db: true
restoreNamespace: dev
dataSource:
repository: s3-mongodb-repo
snapshot: latest
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ aliases:
## User Guide

- [Quickstart PostgreSQL](/docs/guides/postgres/quickstart/quickstart.md) with KubeDB Operator.
- How to [Backup & Restore](/docs/guides/postgres/backup/overview/index.md) PostgreSQL database using Stash.
- How to [Backup & Restore](/docs/guides/postgres/backup/stash/overview/index.md) PostgreSQL database using Stash.
- Initialize [PostgreSQL with Script](/docs/guides/postgres/initialization/script_source.md).
- [PostgreSQL Clustering](/docs/guides/postgres/clustering/ha_cluster.md) supported by KubeDB Postgres.
- [Streaming Replication](/docs/guides/postgres/clustering/streaming_replication.md) for PostgreSQL clustering.
Expand Down
10 changes: 10 additions & 0 deletions docs/guides/postgres/backup/kubestash/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Backup & Restore PostgreSQL | KubeStash
menu:
docs_{{ .version }}:
identifier: guides-pg-backup-stashv2
name: KubeStash (aka Stash 2.0)
parent: guides-pg-backup
weight: 50
menu_name: docs_{{ .version }}
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: core.kubestash.com/v1alpha1
kind: BackupConfiguration
metadata:
name: sample-postgres-backup
namespace: demo
spec:
target:
apiGroup: kubedb.com
kind: Postgres
namespace: demo
name: sample-postgres
backends:
- name: gcs-backend
storageRef:
namespace: demo
name: gcs-storage
retentionPolicy:
name: demo-retention
namespace: demo
sessions:
- name: frequent-backup
scheduler:
schedule: "*/5 * * * *"
jobTemplate:
backoffLimit: 1
repositories:
- name: gcs-postgres-repo
backend: gcs-backend
directory: /postgres
encryptionSecret:
name: encrypt-secret
namespace: demo
addon:
name: postgres-addon
tasks:
- name: manifest-backup
- name: logical-backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: storage.kubestash.com/v1alpha1
kind: BackupStorage
metadata:
name: gcs-storage
namespace: demo
spec:
storage:
provider: gcs
gcs:
bucket: kubestash-qa
prefix: demo
secretName: gcs-secret
usagePolicy:
allowedNamespaces:
from: All
default: true
deletionPolicy: Delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: core.kubestash.com/v1alpha1
kind: RestoreSession
metadata:
name: restore-sample-postgres
namespace: demo
spec:
manifestOptions:
postgres:
db: true
restoreNamespace: dev
dataSource:
repository: gcs-postgres-repo
snapshot: latest
encryptionSecret:
name: encrypt-secret
namespace: demo
addon:
name: postgres-addon
tasks:
- name: logical-backup-restore
- name: manifest-restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: storage.kubestash.com/v1alpha1
kind: RetentionPolicy
metadata:
name: demo-retention
namespace: demo
spec:
default: true
failedSnapshots:
last: 2
maxRetentionPeriod: 2mo
successfulSnapshots:
last: 5
usagePolicy:
allowedNamespaces:
from: All
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kubedb.com/v1
kind: Postgres
metadata:
name: sample-postgres
namespace: demo
spec:
version: "16.1"
replicas: 3
standbyMode: Hot
streamingMode: Synchronous
storageType: Durable
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
deletionPolicy: WipeOut
Loading

0 comments on commit 707e73e

Please sign in to comment.