New: Try our AI‑powered Search (Ctrl + K) — Read more

Dgraph Back and Restore

Prev Next

# Dgraph Backup and Restore

This guide provides detailed procedures for backing up and restoring Dgraph in on-premises Kubernetes PCA deployments.

Prerequisites

  • kubectl access to the PCA cluster
  • SSH access to cluster nodes (for restoration)
  • Familiarity with OpenEBS local storage paths

Backup Overview

Dgraph backups are managed by the stitchit service using configuration from the stitchit-env-config ConfigMap. Unlike other components that use CronJobs, Dgraph backup scheduling is controlled through this ConfigMap.

View the backup configuration:

kubectl describe configmap -n pca stitchit-env-config

Key configuration values:

Setting Description
S3_BUCKET MinIO bucket path for backups
S3_SERVER MinIO server endpoint
BACKUP_SCHEDULE Cron expression for backup timing
BACKUP_RETENTION Retention period (e.g., P15D = 15 days)

Default behavior:

  • Runs daily at 04:00 UTC
  • Writes backups to the local MinIO storage backend
  • Retains backups for 15 days

Manually Trigger a Backup

You can trigger a Dgraph backup using the GraphQL admin API from any pod with curl:

kubectl exec -it -n pca airflow-0 -- sh

First, retrieve the MinIO credentials:

kubectl exec -it -n pca pca-minio-pool-0-0 -- cat /tmp/minio/config.env | grep ROOT

Then execute the backup mutation:

curl -H "Content-Type: application/graphql" -X POST dgraphalpha1-0:8080/admin -d '
mutation {
  export(input: {
    destination: "minio://pca-minio-hl.pca.svc.cluster.local:9000/<bucket-name>?secure=false"
    accessKey: "<MINIO_ROOT_USER>"
    secretKey: "<MINIO_ROOT_PASSWORD>"
  }) {
    response {
      message
      code
    }
  }
}
'

Replace <bucket-name>, <MINIO_ROOT_USER>, and <MINIO_ROOT_PASSWORD> with your actual values.

Alternative: Modify Backup Schedule

You can trigger an immediate backup by temporarily changing the schedule:

  1. Edit the ConfigMap:

    kubectl edit configmap -n pca stitchit-env-config
    
  2. Change BACKUP_SCHEDULE to a time a few minutes in the future

  3. Restart the stitchit deployment:

    kubectl rollout restart deploy -n pca stitchit
    
  4. After the backup completes, restore the original schedule

Access Backups in MinIO

  1. Connect to the MinIO pod:

    kubectl exec -it -n pca pca-minio-pool-0-0 -- sh
    . /tmp/minio/config.env
    
  2. Configure the MinIO client:

    mc alias set --insecure pca https://localhost:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD"
    
  3. List available backups:

    mc --insecure ls pca/<bucket-name>/dgraphBackup/v2/
    
  4. Copy a backup to the pod filesystem:

    mc --insecure cp -r \
      pca/<bucket-name>/dgraphBackup/v2/<backup-folder>/ \
      /tmp/
    

Restore Procedure

Important: Dgraph restoration procedures are complex and depend on your specific deployment configuration. Contact Cisco TAC for guidance on restoring Dgraph data in your environment.

The general restoration approach involves:

  1. Export the backup from MinIO to the admin VM
  2. Stop Dgraph services
  3. Clear existing Dgraph data
  4. Import the backup using Dgraph's bulk loader or live loader
  5. Restart services and validate

Post-Restore Validation

  1. Verify Dgraph cluster health
  2. Confirm data queries return expected results
  3. Check dependent services are functioning correctly

Related Topics