forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
foundationdb-blueprint.yaml
79 lines (79 loc) · 2.82 KB
/
foundationdb-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
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
name: foundationdb-blueprint
actions:
backup:
kind: CustomResource
outputArtifacts:
fdbBackup:
keyValue:
path: '/foundationdb-backups/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}/backup.tgz'
phases:
- func: KubeExec
name: TakeBackup
args:
namespace: "{{ .Object.metadata.namespace }}"
pod: "{{ .Object.metadata.name }}-2"
container: foundationdb
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
#we are manually starting backup_aegnt here because fdb operator doesnt have support for
# backup and restore right now. But they are planning to have it, going further.
# Once they have the support for backup and restore we will change this to accommodate upstream changes
/usr/bin/backup_agent -C /var/dynamic-conf/fdb.cluster &
mkdir -p /data/fdbbackup
chmod -R 777 /data/fdbbackup
fdbbackup start -d file:///data/fdbbackup -w
pkill -9 backup_agent
tar zcvf - -C /data/ fdbbackup | kando location push --profile '{{ toJson .Profile }}' --path '/foundationdb-backups/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}/backup.tgz' -
rm -rf /data/fdbbackup
restore:
kind: CustomResource
inputArtifactNames:
- fdbBackup
phases:
- func: KubeExec
name: restoreBackup
args:
namespace: "{{ .Object.metadata.namespace }}"
pod: "{{ .Object.metadata.name }}-2"
container: foundationdb
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
mkdir -p /data/restored
kando location pull --profile '{{ toJson .Profile }}' --path '{{ .ArtifactsIn.fdbBackup.KeyValue.path }}' - | tar zxvf - -C /data/restored
/usr/bin/backup_agent -C /var/dynamic-conf/fdb.cluster &
fdbcli --exec "writemode on; clearrange '' \xFF"
backupname=$(ls /data/restored/fdbbackup/)
fdbrestore start --dest_cluster_file /var/dynamic-conf/fdb.cluster -r file:///data/restored/fdbbackup/$backupname -w
pkill -9 backup_agent
delete:
phases:
- func: KubeTask
name: deleteBackup
args:
namespace: "{{ .Namespace.Name }}"
image: ghcr.io/kanisterio/kanister-tools:0.22.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
s3path='{{ .ArtifactsIn.fdbBackup.KeyValue.path }}'
kando location delete --profile '{{ toJson .Profile }}' --path ${s3path}