Skip to content

Commit

Permalink
customize backup restore job complete doc
Browse files Browse the repository at this point in the history
Signed-off-by: Neaj Morshad <[email protected]>
  • Loading branch information
Neaj-Morshad-101 committed Sep 20, 2024
1 parent 7b1466e commit 42e3a6a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ spec:
tasks:
- name: logical-backup
params:
args: --clean
args: "-db 1"

This file was deleted.

75 changes: 12 additions & 63 deletions docs/guides/redis/backup/kubestash/customization/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: PostgreSQL Backup Customization | KubeStash
description: Customizing PostgreSQL Backup and Restore process with KubeStash
title: Redis Backup Customization | KubeStash
description: Customizing Redis Backup and Restore process with KubeStash
menu:
docs_{{ .version }}:
identifier: guides-rd-backup-customization-stashv2
Expand All @@ -21,9 +21,9 @@ In this section, we are going to show you how to customize the backup process. H

### Passing arguments to the backup process

KubeStash PostgreSQL addon uses the [rd_dumpall](https://www.redisql.org/docs/current/app-rd-dumpall.html) command by default for backups. However, you can change the dump command to [rd_dump](https://www.redisql.org/docs/current/app-rddump.html) by setting the `backupCmd` parameter under the `addon.tasks[*].params` section. You can pass supported options for either `rd_dumpall` or `rd_dump` through the `args` parameter in the same section.
KubeStash Redis addon uses [redis-dump-go](https://github.com/yannh/redis-dump-go) for backup. You can pass arguments to the redis-dump-go through args parameter under `addon.tasks[*].params` section.

The below example shows how you can pass the `--clean` to include SQL commands to clean (drop) databases before recreating them.
The below example shows how you can pass the `-db 1` to take backup only the database with index 1.

```yaml
apiVersion: core.kubestash.com/v1alpha1
Expand Down Expand Up @@ -63,60 +63,9 @@ spec:
tasks:
- name: logical-backup
params:
args: --clean
args: "-db 1"
```
### Passing a target database to the backup process
KubeStash PostgreSQL addon uses the [rd_dumpall](https://www.redisql.org/docs/current/app-rd-dumpall.html) command by default for backups. If you want to back up a single database, you’ll need to switch the command to [rd_dump](https://www.redisql.org/docs/current/app-rddump.html). You can do this by setting `backupCmd` to `rd_dump` under the `addon.tasks[*].params` section and specifying the database name using the `args` parameter in the same section.

The below example shows how you can set `rd_dump` and pass target database name during backup.

```yaml
apiVersion: core.kubestash.com/v1alpha1
kind: BackupConfiguration
metadata:
name: sample-redis-backup
namespace: demo
spec:
target:
apiGroup: kubedb.com
kind: Redis
namespace: demo
name: sample-redis
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-redis-repo
backend: gcs-backend
directory: /redis
encryptionSecret:
name: encrypt-secret
namespace: demo
addon:
name: redis-addon
tasks:
- name: logical-backup
params:
backupCmd: rd_dump
args: testdb
```

> **WARNING**: Make sure that your provided database has been created before taking backup.

### Using multiple backends
You can configure multiple backends within a single `backupConfiguration`. To back up the same data to different backends, such as S3 and GCS, declare each backend in the `.spe.backends` section. Then, reference these backends in the `.spec.sessions[*].repositories` section.
Expand Down Expand Up @@ -277,11 +226,11 @@ spec:

## Customizing Restore Process

`KubeStash` uses [psql](https://www.redisql.org/docs/current/app-psql.html) during the restore process. In this section, we are going to show how you can pass arguments to the restore process, restore a specific snapshot, run restore job as a specific user, etc.
`KubeStash` uses `redis-cli` during the restore process. In this section, we are going to show how you can pass arguments to the restore process, restore a specific snapshot, run restore job as a specific user, etc.

### Passing arguments to the restore process

You can pass any supported `psql` arguments to the restore process using the `args` field within the `addon.tasks[*].params` section. This example demonstrates how to specify a database `testdb` to connect to during the restore process.
Similar to the backup process, you can pass arguments to the restore process through the `args` field within the `addon.tasks[*].params` section. Here, we have passed --pipe-timeout argument to the redis-cli.

```yaml
apiVersion: core.kubestash.com/v1alpha1
Expand All @@ -306,7 +255,7 @@ spec:
tasks:
- name: logical-backup-restore
params:
args: --dbname=testdb
args: "--pipe-timeout 300"
```

### Restore specific snapshot
Expand All @@ -316,10 +265,10 @@ You can also restore a specific snapshot. At first, list the available snapshot
```bash
$ kubectl get snapshots.storage.kubestash.com -n demo -l=kubestash.com/repo-name=gcs-redis-repo
NAME REPOSITORY SESSION SNAPSHOT-TIME DELETION-POLICY PHASE AGE
gcs-redis-repo-sample-redis-backup-frequent-backup-1725257849 gcs-redis-repo frequent-backup 2024-09-02T06:18:01Z Delete Succeeded 15m
gcs-redis-repo-sample-redis-backup-frequent-backup-1725258000 gcs-redis-repo frequent-backup 2024-09-02T06:20:00Z Delete Succeeded 13m
gcs-redis-repo-sample-redis-backup-frequent-backup-1725258300 gcs-redis-repo frequent-backup 2024-09-02T06:25:00Z Delete Succeeded 8m34s
gcs-redis-repo-sample-redis-backup-frequent-backup-1725258600 gcs-redis-repo frequent-backup 2024-09-02T06:30:00Z Delete Succeeded 3m34s
gcs-redis-repo-sample-redis-backup-frequent-backup-1725257849 gcs-redis-repo frequent-backup 2024-09-02T06:18:01Z Delete Succeeded 15m
gcs-redis-repo-sample-redis-backup-frequent-backup-1725258000 gcs-redis-repo frequent-backup 2024-09-02T06:20:00Z Delete Succeeded 13m
gcs-redis-repo-sample-redis-backup-frequent-backup-1725258300 gcs-redis-repo frequent-backup 2024-09-02T06:25:00Z Delete Succeeded 8m34s
gcs-redis-repo-sample-redis-backup-frequent-backup-1725258600 gcs-redis-repo frequent-backup 2024-09-02T06:30:00Z Delete Succeeded 3m34s
```

The below example shows how you can pass a specific snapshot name in `.spec.dataSource` section.
Expand Down

0 comments on commit 42e3a6a

Please sign in to comment.