Restore the GraphDB
This guide shows you how to restore the Graph database in your Rhize environment.
Prerequisites
Before you start, ensure you have the following:
- The GraphDB Helm chart
kubectl- A Database backup
Steps
Confirm the cluster and namespace are correct.
## context kubectl config current-context ## namespace kubectl get namespaceTo change the namespace for all subsequent
kubectlcommands tolibre, run this command:kubectl config set-context --current --namespace=libreChange to the libre-baas helm chart overrides,
baas.yaml. Setalpha.initContainers.init.enabletotrue.Upgrade or install the Helm chart.
helm upgrade --install -f baas.yaml libre-baas libre/baas -n libreIn the Alpha 0 initialization container, create the backup directory.
kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- \ mkdir -p /dgraph/backupsIf the backup directory does not have a checksums file, create one.
sha256sum ./<PATH_TO_BACKUP>/*.gz > ./<PATH_TO_BACKUP>/backup.sumsCopy the backup into the initialization container.
kubectl cp --retries=10 ./<PATH_TO_BACKUP> \ libre-baas-alpha-0:/dgraph/backups/<PATH_TO_BACKUP> \ -c libre-baas-alpha-initAfter the process finishes, confirm that the checksums match:
kubectl exec -it libre-baas-alpha-0 -c libre-baas-alpha-init -- \ 'sha256sum -c /dgraph/backups/<PATH_TO_BACKUP>/backup.sums /dgraph/backups/<PATH_TO_BACKUP>/*.gz'Restore the backup to the restore directory. Replace the
<PATH_TO_BACKUP>and<NAMESPACE>in the arguments for the following command:kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- \ dgraph bulk -f /dgraph/backups/<PATH_TO_BACKUP>/g01.json.gz \ -g /dgraph/backups/<PATH_TO_BACKUP>/g01.gql_schema.gz \ -s /dgraph/backups/<PATH_TO_BACKUP>/g01.schema.gz \ --zero=libre-baas-zero-0.libre-baas-zero-headless.<NAMESPACE>.svc.cluster.local:5080 \ --out /dgraph/restore --replace_outCopy the backup to the correct directory:
kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- \ mv /dgraph/restore/0/p /dgraph/pComplete the initialization container for alpha 0.
kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- touch /dgraph/doneinitWait for
libre-baas-alpha-0to start serving the GraphQL API.Repeat the process, starting from step 4, for each Alpha replica.
In each step replace
libre-baas-alpha-0withlibre-baas-alpha-<REPLICA-NUMBER>, where<REPLICA-NUMBER>is the current Alpha replica being restored.