-
Notifications
You must be signed in to change notification settings - Fork 148
/
couchbase-blueprint.yaml
103 lines (101 loc) · 4.07 KB
/
couchbase-blueprint.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
name: couchbase-blueprint
actions:
backup:
kind: CustomResource
outputArtifacts:
cbBackup:
# Capture the kopia snapshot information for subsequent actions
# The information includes the kopia snapshot ID which is essential for restore and delete to succeed
# `kopiaOutput` is the name provided to kando using `--output-name` flag
kopiaSnapshot: "{{ .Phases.TakeBackup.Output.kopiaOutput }}"
phases:
- func: KubeTask
name: TakeBackup
objects:
authSecret:
kind: Secret
name: "{{ .Object.spec.security.adminSecret }}"
namespace: "{{ .Object.metadata.namespace }}"
args:
namespace: "{{ .Object.metadata.namespace }}"
image: ghcr.io/kanisterio/couchbase-tools:0.58.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
rm -rf /backups/test
mkdir -p /backups/test
cbbackupmgr config --archive /backups/test --repo couchbase
cbbackupmgr backup \
--archive /backups/test \
--repo couchbase \
--cluster couchbase://{{ .Object.metadata.name }}.{{ .Object.metadata.namespace }}.svc \
--username {{ .Phases.TakeBackup.Secrets.authSecret.Data.username | toString }} \
--password {{ .Phases.TakeBackup.Secrets.authSecret.Data.password | toString }}
backup_file_path='backup.tgz'
tar zcvf - -C /backups/ test | kando location push --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --output-name "kopiaOutput" -
restore:
kind: CustomResource
inputArtifactNames:
# The kopia snapshot info created in backup phase can be used here
# Use the `--kopia-snapshot` flag in kando to pass in `cbBackup.KopiaSnapshot`
- cbBackup
phases:
- func: KubeTask
name: restoreBackup
objects:
authSecret:
kind: Secret
name: "{{ .Object.spec.security.adminSecret }}"
namespace: "{{ .Object.metadata.namespace }}"
args:
namespace: "{{ .Object.metadata.namespace }}"
image: ghcr.io/kanisterio/couchbase-tools:0.53.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
rm -rf /backups/test
mkdir -p /backups/test
backup_file_path='backup.tgz'
kando location pull --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --kopia-snapshot '{{ .ArtifactsIn.cbBackup.KopiaSnapshot }}' - | tar zxvf - -C /backups/
cbbackupmgr restore \
--archive /backups/test \
--repo couchbase \
--cluster couchbase://{{ .Object.metadata.name }}.{{ .Object.metadata.namespace }}.svc \
--username {{ .Phases.restoreBackup.Secrets.authSecret.Data.username | toString }} \
--password {{ .Phases.restoreBackup.Secrets.authSecret.Data.password | toString }} \
--force-updates
delete:
type: Namespace
inputArtifactNames:
# The kopia snapshot info created in backup phase can be used here
# Use the `--kopia-snapshot` flag in kando to pass in `cbBackup.KopiaSnapshot`
- cbBackup
phases:
- func: KubeTask
name: deleteBackup
args:
namespace: "{{ .Namespace.Name }}"
image: ghcr.io/kanisterio/couchbase-tools:0.53.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
backup_file_path='backup.tgz'
kando location delete --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --kopia-snapshot '{{ .ArtifactsIn.cbBackup.KopiaSnapshot }}'