Skip to content
⚠️
You are viewing the documentation for Rhize v3.3.1. View the latest.

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:

Steps

  1. Confirm the cluster and namespace are correct.

    ## context
    kubectl config current-context
    ## namespace
    kubectl get namespace

    To change the namespace for all subsequent kubectl commands to libre, run this command:

    kubectl config set-context --current --namespace=libre
  2. Change to the libre-baas helm chart overrides, baas.yaml. Set alpha.initContainers.init.enable to true.

  3. Upgrade or install the Helm chart.

    helm upgrade --install -f baas.yaml libre-baas libre/baas -n libre
  4. In the Alpha 0 initialization container, create the backup directory.

    kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- \
    mkdir -p /dgraph/backups
  5. If the backup directory does not have a checksums file, create one.

    sha256sum ./<PATH_TO_BACKUP>/*.gz > ./<PATH_TO_BACKUP>/backup.sums
  6. Copy 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-init

    After 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'
  7. 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_out
  8. Copy the backup to the correct directory:

    kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- \
    mv /dgraph/restore/0/p /dgraph/p
  9. Complete the initialization container for alpha 0.

    kubectl exec -t libre-baas-alpha-0 -c libre-baas-alpha-init -- touch /dgraph/doneinit
  10. Wait for libre-baas-alpha-0 to start serving the GraphQL API.

  11. Repeat the process, starting from step 4, for each Alpha replica.

    In each step replace libre-baas-alpha-0 with libre-baas-alpha-<REPLICA-NUMBER>, where <REPLICA-NUMBER> is the current Alpha replica being restored.