Skip to content

Commit

Permalink
Add MariaDB Addon for Backup and Restore with Restic (#876)
Browse files Browse the repository at this point in the history
Signed-off-by: SK Ali Arman <[email protected]>
Signed-off-by: hmsayem <[email protected]>
Co-authored-by: hmsayem <[email protected]>
  • Loading branch information
sheikh-arman and hmsayem authored Mar 4, 2024
1 parent 0ba427b commit bf44eef
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apis/installer/v1alpha1/kubedb_kubestash_catalog_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type KubedbKubestashCatalogSpec struct {
Kubedbmanifest StashKubedbmanifestSpec `json:"kubedbmanifest"`
Mongodb StashMongodbSpec `json:"mongodb"`
Mysql StashMysqlSpec `json:"mysql"`
Mariadb StashMariadbSpec `json:"mariadb"`
Redis StashRedisSpec `json:"redis"`
Postgres StashPostgresSpec `json:"postgres"`
}
Expand Down Expand Up @@ -136,6 +137,21 @@ type MySQLRestore struct {
Args string `json:"args"`
}

type StashMariadbSpec struct {
Backup MariaDBBackup `json:"backup"`
Restore MariaDBRestore `json:"restore"`
}

type MariaDBBackup struct {
// +optional
Args string `json:"args"`
}

type MariaDBRestore struct {
// +optional
Args string `json:"args"`
}

// StashRedisSpec is the schema for Stash Redis values file
type StashRedisSpec struct {
Backup RedisBackup `json:"backup"`
Expand Down
51 changes: 51 additions & 0 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions catalog/kubestash/raw/mariadb/mariadb-addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
apiVersion: addons.kubestash.com/v1alpha1
kind: Addon
metadata:
name: mariadb-addon
spec:
backupTasks:
- name: logical-backup
function: mariadb-backup
driver: Restic
executor: Job
singleton: true
parameters:
- name: args
usage: Arguments to be passed to the dump command.
required: false
default: "--all-databases"
- 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: manifest-backup
function: kubedbmanifest-backup
driver: Restic
executor: Job
singleton: true
parameters:
- 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
restoreTasks:
- name: logical-backup-restore
function: mariadb-restore
driver: Restic
executor: Job
singleton: true
parameters:
- name: args
usage: Arguments to be passed to the dump command.
required: false
- 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: manifest-restore
function: kubedbmanifest-restore
driver: Restic
executor: Job
singleton: true
parameters:
- 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
15 changes: 15 additions & 0 deletions catalog/kubestash/raw/mariadb/mariadb-backup-function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: addons.kubestash.com/v1alpha1
kind: Function
metadata:
name: mariadb-backup
spec:
args:
- backup
- --namespace=${namespace:=default}
- --backupsession=${backupSession:=}
- --enable-cache=${enableCache:=}
- --scratch-dir=${scratchDir:=}
- --wait-timeout=${waitTimeout:=300}
- --mariadb-args=${args:=}
- --db-version=${dbVersion:=}
image: skaliarman/mariadb-restic-plugin:restic-backup_linux_amd64test12
16 changes: 16 additions & 0 deletions catalog/kubestash/raw/mariadb/mariadb-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: mariadb-restore
spec:
args:
- restore
- --namespace=${namespace:=default}
- --restoresession=${restoreSession:=}
- --snapshot=${snapshot:=}
- --enable-cache=${enableCache:=}
- --scratch-dir=${scratchDir:=}
- --wait-timeout=${waitTimeout:=300}
- --mariadb-args=${args:=}
- --db-version=${dbVersion:=}
image: skaliarman/mariadb-restic-plugin:restic-backup_linux_amd64test12
2 changes: 2 additions & 0 deletions charts/kubedb-kubestash-catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ The following table lists the configurable parameters of the `kubedb-kubestash-c
| postgres.restore.args | Arguments to pass to `psql` command during restore process | <code>""</code> |
| mysql.backup.args | Arguments to pass to `mysqldump` command during bakcup process | <code>""</code> |
| mysql.restore.args | Arguments to pass to `mysql` command during restore process | <code>""</code> |
| mariadb.backup.args | Arguments to pass to `mariadb-dump` command during bakcup process | <code>""</code> |
| mariadb.restore.args | Arguments to pass to `mariadb` command during restore process | <code>""</code> |
| redis.backup.args | Arguments to pass to `redis-dump` command during bakcup process | <code>""</code> |
| redis.restore.args | Arguments to pass to `redis` command during restore process | <code>""</code> |

Expand Down
111 changes: 111 additions & 0 deletions charts/kubedb-kubestash-catalog/templates/mariadb/mariadb-addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{{ $featureGates := .Values.featureGates }}
{{- if .Values.global }}
{{ $featureGates = mergeOverwrite dict .Values.featureGates .Values.global.featureGates }}
{{- end }}

{{ if $featureGates.MariaDB }}
apiVersion: addons.kubestash.com/v1alpha1
kind: Addon
metadata:
name: 'mariadb-addon'
labels:
{{- include "kubedb-kubestash-catalog.labels" . | nindent 4 }}
spec:
backupTasks:
- driver: Restic
executor: Job
function: mariadb-backup
name: logical-backup
parameters:
- default: --all-databases
name: args
required: false
usage: Arguments to be passed to the dump command.
- 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-backup
name: manifest-backup
parameters:
- 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.
restoreTasks:
- driver: Restic
executor: Job
function: mariadb-restore
name: logical-backup-restore
parameters:
- name: args
required: false
usage: Arguments to be passed to the dump command.
- 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
name: manifest-restore
parameters:
- 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.
{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ $featureGates := .Values.featureGates }}
{{- if .Values.global }}
{{ $featureGates = mergeOverwrite dict .Values.featureGates .Values.global.featureGates }}
{{- end }}

{{ if $featureGates.MariaDB }}
apiVersion: addons.kubestash.com/v1alpha1
kind: Function
metadata:
name: 'mariadb-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}}}
- --mariadb-args=${args:={{ .Values.mariadb.args }}}
- --db-version=${dbVersion:=}
image: '{{ include "image.dockerHub" (merge (dict "_repo" "skaliarman/mariadb-restic-plugin") $) }}:restic-backup_linux_amd64test12'
{{ end }}
Loading

0 comments on commit bf44eef

Please sign in to comment.