Skip to content

Commit

Permalink
Add postgres restic addon
Browse files Browse the repository at this point in the history
Signed-off-by: hmsayem <[email protected]>
  • Loading branch information
hmsayem committed Nov 30, 2023
1 parent 45b0125 commit af13353
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 0 deletions.
62 changes: 62 additions & 0 deletions catalog/kubestash/raw/postgres/postgres-addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ metadata:
name: postgres-addon
spec:
backupTasks:
- name: LogicalBackup
function: postgres-backup
driver: Restic
executor: Job
singleton: true
parameters:
- name: args
usage: Arguments to be passed to the dump command.
required: false
- name: backupCmd
usage: Backup command to take a database dump (can only be pg_dumpall or pg_dump)
required: false
default: "pg_dumpall"
- name: user
usage: Specifies database user (not applicable for basic authentication)
required: false
default: "postgres"
- name: enableCache
usage: Enable or disable caching. Disabling caching may impact backup performance.
required: false
default: "true"
- name: scratchDir
usage: Directory for holding temporary files and restic cache.
required: false
default: /kubestash-tmp
volumeTemplate:
- name: kubestash-tmp-volume
usage: Holds temporary files and restic cache.
source:
emptyDir: {}
volumeMounts:
- name: kubestash-tmp-volume
mountPath: /kubestash-tmp
- name: VolumeSnapshot
function: postgres-csisnapshotter
driver: VolumeSnapshotter
Expand Down Expand Up @@ -36,6 +69,35 @@ spec:
- name: kubestash-tmp-volume
mountPath: /kubestash-tmp
restoreTasks:
- name: LogicalBackupRestore
function: postgres-restore
driver: Restic
executor: Job
singleton: true
parameters:
- name: args
usage: Arguments to be passed to the dump command.
required: false
- name: user
usage: Specifies database user (not applicable for basic authentication)
required: false
default: "postgres"
- name: enableCache
usage: Enable or disable caching. Disabling caching may impact backup performance.
required: false
default: "true"
- name: scratchDir
usage: Directory for holding temporary files and restic cache.
required: false
default: /kubestash-tmp
volumeTemplate:
- name: kubestash-tmp-volume
usage: Holds temporary files and restic cache.
source:
emptyDir: {}
volumeMounts:
- name: kubestash-tmp-volume
mountPath: /kubestash-tmp
- name: ManifestRestore
function: kubedbmanifest-restore
driver: Restic
Expand Down
16 changes: 16 additions & 0 deletions catalog/kubestash/raw/postgres/postgres-backup-function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: addons.kubestash.com/v1alpha1
kind: Function
metadata:
name: postgres-backup
spec:
args:
- backup
- --namespace=${namespace:=default}
- --backupsession=${backupSession:=}
- --enable-cache=${enableCache:=}
- --scratch-dir=${scratchDir:=}
- --wait-timeout=${waitTimeout:=300}
- --pg-args=${args:=}
- --backup-cmd=${backupCmd:=}
- --user=${user:=}
image: ghcr.io/kubedb/postgres-restic-plugin:v0.1.0-rc.0
16 changes: 16 additions & 0 deletions catalog/kubestash/raw/postgres/postgres-restore-function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: addons.kubestash.com/v1alpha1
kind: Function
metadata:
name: postgres-restore
spec:
args:
- restore
- --namespace=${namespace:=default}
- --restoresession=${restoreSession:=}
- --snapshot=${snapshot:=}
- --enable-cache=${enableCache:=}
- --scratch-dir=${scratchDir:=}
- --wait-timeout=${waitTimeout:=300}
- --pg-args=${args:=}
- --user=${user:=}
image: ghcr.io/kubedb/postgres-restic-plugin:v0.1.0-rc.0
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ metadata:
{{- include "kubedb-kubestash-catalog.labels" . | nindent 4 }}
spec:
backupTasks:
- driver: Restic
executor: Job
function: postgres-backup
name: LogicalBackup
parameters:
- name: args
required: false
usage: Arguments to be passed to the dump command.
- default: pg_dumpall
name: backupCmd
required: false
usage: Backup command to take a database dump (can only be pg_dumpall or pg_dump)
- default: postgres
name: user
required: false
usage: Specifies database user (not applicable for basic authentication)
- default: "true"
name: enableCache
required: false
usage: Enable or disable caching. Disabling caching may impact backup performance.
- default: /kubestash-tmp
name: scratchDir
required: false
usage: Directory for holding temporary files and restic cache.
singleton: true
volumeMounts:
- mountPath: /kubestash-tmp
name: kubestash-tmp-volume
volumeTemplate:
- name: kubestash-tmp-volume
source:
emptyDir: {}
usage: Holds temporary files and restic cache.
- driver: VolumeSnapshotter
executor: Job
function: postgres-csisnapshotter
Expand Down Expand Up @@ -39,6 +72,35 @@ spec:
emptyDir: {}
usage: Holds temporary files and restic cache.
restoreTasks:
- driver: Restic
executor: Job
function: postgres-restore
name: LogicalBackupRestore
parameters:
- name: args
required: false
usage: Arguments to be passed to the dump command.
- default: postgres
name: user
required: false
usage: Specifies database user (not applicable for basic authentication)
- default: "true"
name: enableCache
required: false
usage: Enable or disable caching. Disabling caching may impact backup performance.
- default: /kubestash-tmp
name: scratchDir
required: false
usage: Directory for holding temporary files and restic cache.
singleton: true
volumeMounts:
- mountPath: /kubestash-tmp
name: kubestash-tmp-volume
volumeTemplate:
- name: kubestash-tmp-volume
source:
emptyDir: {}
usage: Holds temporary files and restic cache.
- driver: Restic
executor: Job
function: kubedbmanifest-restore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ if .Values.postgres.enabled }}
apiVersion: addons.kubestash.com/v1alpha1
kind: Function
metadata:
name: 'postgres-backup'
labels:
{{- include "kubedb-kubestash-catalog.labels" . | nindent 4 }}
spec:
args:
- backup
- --namespace=${namespace:=default}
- --backupsession=${backupSession:=}
- --enable-cache=${enableCache:=}
- --scratch-dir=${scratchDir:=}
- --wait-timeout=${waitTimeout:={{ .Values.waitTimeout}}}
- --pg-args=${args:={{ .Values.postgres.args }}}
- --backup-cmd=${backupCmd:=}
- --user=${user:=}
image: '{{ include "image.ghcr" (merge (dict "_repo" "kubedb/postgres-restic-plugin") $) }}:v0.1.0-rc.0'
{{ end }}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ if .Values.postgres.enabled }}
apiVersion: addons.kubestash.com/v1alpha1
kind: Function
metadata:
name: 'postgres-restore'
labels:
{{- include "kubedb-kubestash-catalog.labels" . | nindent 4 }}
spec:
args:
- restore
- --namespace=${namespace:=default}
- --restoresession=${restoreSession:=}
- --snapshot=${snapshot:=}
- --enable-cache=${enableCache:=}
- --scratch-dir=${scratchDir:=}
- --wait-timeout=${waitTimeout:={{ .Values.waitTimeout}}}
- --pg-args=${args:={{ .Values.postgres.args }}}
- --user=${user:=}
image: '{{ include "image.ghcr" (merge (dict "_repo" "kubedb/postgres-restic-plugin") $) }}:v0.1.0-rc.0'
{{ end }}

0 comments on commit af13353

Please sign in to comment.