diff --git a/catalog/kubestash/raw/postgres/postgres-addon.yaml b/catalog/kubestash/raw/postgres/postgres-addon.yaml index 4c2aee3ef..813a04767 100644 --- a/catalog/kubestash/raw/postgres/postgres-addon.yaml +++ b/catalog/kubestash/raw/postgres/postgres-addon.yaml @@ -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 @@ -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 diff --git a/catalog/kubestash/raw/postgres/postgres-backup-function.yaml b/catalog/kubestash/raw/postgres/postgres-backup-function.yaml new file mode 100644 index 000000000..dccebf6bb --- /dev/null +++ b/catalog/kubestash/raw/postgres/postgres-backup-function.yaml @@ -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 diff --git a/catalog/kubestash/raw/postgres/postgres-restore-function.yaml b/catalog/kubestash/raw/postgres/postgres-restore-function.yaml new file mode 100644 index 000000000..4d9695e57 --- /dev/null +++ b/catalog/kubestash/raw/postgres/postgres-restore-function.yaml @@ -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 diff --git a/charts/kubedb-kubestash-catalog/templates/postgres/postgres-addon.yaml b/charts/kubedb-kubestash-catalog/templates/postgres/postgres-addon.yaml index fb6c74c4e..3bc9d112f 100644 --- a/charts/kubedb-kubestash-catalog/templates/postgres/postgres-addon.yaml +++ b/charts/kubedb-kubestash-catalog/templates/postgres/postgres-addon.yaml @@ -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 @@ -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 diff --git a/charts/kubedb-kubestash-catalog/templates/postgres/postgres-backup.yaml b/charts/kubedb-kubestash-catalog/templates/postgres/postgres-backup.yaml new file mode 100644 index 000000000..04d8e759f --- /dev/null +++ b/charts/kubedb-kubestash-catalog/templates/postgres/postgres-backup.yaml @@ -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 }} + diff --git a/charts/kubedb-kubestash-catalog/templates/postgres/postgres-restore.yaml b/charts/kubedb-kubestash-catalog/templates/postgres/postgres-restore.yaml new file mode 100644 index 000000000..b2eb4a255 --- /dev/null +++ b/charts/kubedb-kubestash-catalog/templates/postgres/postgres-restore.yaml @@ -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 }} +