# Dgraph Backup and Restore
This guide provides detailed procedures for backing up and restoring Dgraph in on-premises Kubernetes PCA deployments.
Prerequisites
kubectlaccess 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:
-
Edit the ConfigMap:
kubectl edit configmap -n pca stitchit-env-config -
Change
BACKUP_SCHEDULEto a time a few minutes in the future -
Restart the stitchit deployment:
kubectl rollout restart deploy -n pca stitchit -
After the backup completes, restore the original schedule
Access Backups in MinIO
-
Connect to the MinIO pod:
kubectl exec -it -n pca pca-minio-pool-0-0 -- sh . /tmp/minio/config.env -
Configure the MinIO client:
mc alias set --insecure pca https://localhost:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD" -
List available backups:
mc --insecure ls pca/<bucket-name>/dgraphBackup/v2/ -
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:
- Export the backup from MinIO to the admin VM
- Stop Dgraph services
- Clear existing Dgraph data
- Import the backup using Dgraph's bulk loader or live loader
- Restart services and validate
Post-Restore Validation
- Verify Dgraph cluster health
- Confirm data queries return expected results
- Check dependent services are functioning correctly