Skip to content

Commit 5ef23b5

Browse files
committed
feat: update backup and restore procedure for graphdb
Updates backup procedure to include instructions for using BAAS Console.
1 parent a07e4db commit 5ef23b5

2 files changed

Lines changed: 39 additions & 45 deletions

File tree

content/latest/deploy/backup/graphdb.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ Before you start, ensure you have the following:
2222
{{% param pre_reqs %}}.
2323

2424

25-
Before you start, confirm you are in the right context and namespace:
25+
Before you start, you will need to do the following:
2626

27-
{{% param "k8s_cluster_ns" %}}
28-
29-
## Steps
27+
1. Confirm you are in the right context and namespace:
3028

31-
To back up the database, follow these steps:
29+
{{% param "k8s_cluster_ns" %}}
3230

3331
1. Check the logs for the alpha and zero pods, either in Lens or with [`kubectl logs`](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#logs).
3432
Ensure there are no errors.
@@ -46,6 +44,36 @@ To back up the database, follow these steps:
4644

4745
For details, read the Kubernetes topic [Get Shell to a Running Container](https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/).
4846

47+
## Steps
48+
49+
To back up the database, you will need to first trigger a backup, and then retrieve the backup using `kubectl`.
50+
51+
### Backup
52+
53+
To back up the database, you can use either of the following methods:
54+
55+
#### BAAS Console
56+
57+
This method will use BAAS's web console to trigger a backup.
58+
59+
1. Navigate to `<baas-url>/console` in your browser of choice.
60+
61+
1. Login to the BAAS Console with your Keycloak credentials.
62+
63+
1. Click "Backups" > "Local Export".
64+
65+
{{< callout type="info" >}}
66+
Database backups support S3/Minio and includes an option to list backups in a specific destination. For this guide we will be performing a local backup.
67+
{{< /callout >}}
68+
69+
1. Enter your designated backup location along with the backup name, or use the default provided.
70+
71+
1. Click "Start Export" and wait for the operation to finish. A dialogue should appear saying "Export Completed Successfully".
72+
73+
#### Alpha Pod Shell
74+
75+
This option will use the shell opened in the prerequisites to trigger a backup.
76+
4977
1. Make a POST request to your Keycloak `/token` endpoint to get an `access_token` value.
5078
For example, with `curl` and `jq`:
5179
@@ -73,6 +101,10 @@ For example, with `curl`:
73101
--data-raw '{"query":"mutation {\r\n export(input: {format: \"json\", destination: \"/dgraph/backups/'"$(date +"%Y-%m-%dT%H.%M.%SZ")"'\"}) {\r\n response {\r\n message\r\n code\r\n }\r\n}\r\n}","variables":{}}'
74102
```
75103
104+
### Retrieve
105+
106+
To retrieve the backup, we will need to use the alpha pod shell opened in the prerequisites.
107+
76108
1. Change to the backup directory (the `destination` parameter in the preceding `curl` command). For example:
77109
78110
```bash

content/latest/deploy/restore/graphdb.md

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,44 +97,6 @@ Before you start, ensure you have the following:
9797

9898
1. Wait for `{{< param application_name >}}-baas-alpha-0` to start serving the GraphQL API.
9999

100-
1. Make a database mutation to force a snapshot to be taken.
101-
For example, create a `UnitOfMeasure` then delete it:
100+
1. Repeat the process, starting from step 4, for each Alpha replica.
102101

103-
```bash
104-
kubectl exec -t {{< param application_name >}}-baas-alpha-0 -c {{< param application_name >}}-baas-alpha -- \
105-
curl --location --request POST 'http://localhost:8080/graphql' \
106-
--header 'Content-Type: application/json' \
107-
--data-raw '{"query":"mutation RestoringDatabase($input:[AddUnitOfMeasureInput!]!){\r\n addUnitOfMeasure(input:$input){\r\n unitOfMeasure{\r\n id\r\n dataType\r\n code\r\n }\r\n}\r\n}","variables":{"input":[{"code":"Restoring","isActive":true,"dataType":"BOOL"}]}}'
108-
```
109-
Wait until you see {{< param application_name >}}-baas creating a snapshot in the logs. For example:
110-
111-
```bash
112-
$ kubectl logs {{< param application_name >}}-baas-alpha-0
113-
++ hostname -f
114-
++ awk '{gsub(/\.$/,""); print $0}'
115-
...
116-
I0314 20:32:21.282271 19 draft.go:805] Creating snapshot at Index: 16, ReadTs: 9
117-
```
118-
119-
Revert any database mutations:
120-
121-
```bash
122-
kubectl exec -t {{< param application_name >}}-baas-alpha-0 -c {{< param application_name >}}-baas-alpha -- \
123-
curl --location --request POST 'http://localhost:8080/graphql' \
124-
--header 'Content-Type: application/json' \
125-
--data-raw '{"query":"mutation {\r\n deleteUnitOfMeasure(filter:{code:{eq:\"Restoring\"}}){\r\n unitOfMeasure{\r\n id\r\n }\r\n }\r\n}","variables":{"input":[{"code":"Restoring","isActive":true,"dataType":"BOOL"}]}}'
126-
```
127-
128-
1. Complete the initialization container for alpha 1:
129-
130-
```bash
131-
kubectl exec -t {{< param application_name >}}-baas-alpha-1 -c {{< param application_name >}}-baas-alpha-init -- \
132-
touch /dgraph/doneinit
133-
```
134-
135-
And alpha 2:
136-
137-
```bash
138-
kubectl exec -t {{< param application_name >}}-baas-alpha-2 -c {{< param application_name >}}-baas-alpha-init -- \
139-
touch /dgraph/doneinit
140-
```
102+
In each step replace `{{< param application_name >}}-baas-alpha-0` with `{{< param application_name >}}-baas-alpha-<REPLICA-NUMBER>`, where `<REPLICA-NUMBER>` is the current Alpha replica being restored.

0 commit comments

Comments
 (0)