You are looking at the documentation of a prior release. To read the documentation of the latest release, please
visit here.
Auto Backup for Database
This tutorial will give you an overview of how you can configure Stash auto-backup of the databases and the available configurable options for database auto-backup.
Configuring auto-backup for databases
To configure auto-backup for a database, you have to follow the following steps:
- Create BackupBlueprint: At first, you have to create a
BackupBlueprint
with the template forRepository
andBackupConfiguration
. Use the appropriateTask
in thetask
section. - Create Storage Secret: Then, you have to create a storage Secret in the same namespace as your database with the access credential to your backend. You can re-use this secret to backup the other databases in that namespace.
- Add auto-backup annotations: Finally, add the auto-backup annotations to your database object or the respective
AppBinding
object.
Where to put auto-backup annotations
If you are using KubeDB to manage your databases, you can add the annotations to your database object. KubeDB will automatically pass those annotations to the respective AppBinding
.
If you are not managing your database using KubeDB, you have to add the annotation in the respective AppBinding
that you have created for your database.
Available Auto-Backup Annotations for Database
The following auto-backup annotations are available for the databases:
- BackupBlueprint Name: You have to specify the
BackupBlueprint
name that holds the template forRepository
andBackupConfiguration
in the following annotation:
stash.appscode.com/backup-blueprint: <BackupBlueprint name>
You can also specify multiple BackupBlueprint name separated by comma (,
). For example:
stash.appscode.com/backup-blueprint: daily-gcs-backup,weekly-s3-backup
- Schedule: You can specify a custom schedule for a target to overwrite the schedule of the BackupBlueprint through this annotation.
stash.appscode.com/schedule: <Cron Expression>
- Task Parameters: You can also pass some parameters to the respective backup
Task
through annotations. Use following format to pass parameters via annotations:
params.stash.appscode.com/key1: value1
params.stash.appscode.com/key2: value2,value3
params.stash.appscode.com/key3: ab=123,bc=234
The above parameters will be added in the spec.task.params
section as bellow,
task:
name: postgres-backup-13.1-v1
params:
- name: key1
value: value1
- name: key2
value: value3,value3
- name: key3
value: ab=123,bc=234
Database Auto-backup Examples
You can find auto-backup examples for the databases here: