Protect your Prisme.ai platform data with comprehensive backup and restore procedures
A robust backup and restore strategy is essential for protecting your Prisme.ai platform data and ensuring business continuity. This guide provides detailed instructions for backing up and restoring all components of your self-hosted Prisme.ai environment.
# List databases in the backupfind /path/to/backup/mongo/$(date +%Y-%m-%d) -type d -depth 1# Count documents in a specific collectionmongorestore --uri="mongodb://username:password@hostname:port/database" \ --nsInclude="database.collection" \ --dryRun /path/to/backup/mongo/$(date +%Y-%m-%d) | grep "documents to restore"
# List databases in the backupfind /path/to/backup/mongo/$(date +%Y-%m-%d) -type d -depth 1# Count documents in a specific collectionmongorestore --uri="mongodb://username:password@hostname:port/database" \ --nsInclude="database.collection" \ --dryRun /path/to/backup/mongo/$(date +%Y-%m-%d) | grep "documents to restore"
# Install elasticdumpnpm install -g elasticdump# Backup all indices dataelasticdump \ --input=http://elasticsearch:9200/ \ --output=/path/to/backup/elasticsearch/data_$(date +%Y%m%d).json \ --type=data# Backup index mappingselasticdump \ --input=http://elasticsearch:9200/ \ --output=/path/to/backup/elasticsearch/mapping_$(date +%Y%m%d).json \ --type=mapping
2
Verify Elasticsearch/OpenSearch Backup
Ensure the backup contains all expected indices and data:
Copy
Ask AI
# For snapshot APIcurl -X GET "localhost:9200/_snapshot/backup_repository/snapshot_$(date +%Y%m%d)"# For elasticdumpjq 'keys' /path/to/backup/elasticsearch/mapping_$(date +%Y%m%d).json
# Trigger a SAVE operationredis-cli -h redis-host -a password SAVE# Copy the dump.rdb filecp /path/to/redis/data/dump.rdb /path/to/backup/redis/dump_$(date +%Y%m%d).rdb
Use AWS CLI or compatible tools to back up your S3 storage:
Copy
Ask AI
# Sync to another bucket (cross-region for disaster recovery)aws s3 sync s3://your-prisme-bucket s3://your-backup-bucket# Or sync to local storageaws s3 sync s3://your-prisme-bucket /path/to/backup/s3-data
2
Enable Versioning
Enable versioning on your S3 bucket for built-in backup protection:
# Back up all resources in the Prisme namespacemkdir -p /path/to/backup/kubernetes/$(date +%Y-%m-%d)# Export deployments, services, configmaps, secrets, etc.kubectl get all,pvc,cm,secret -n prisme-system -o yaml > \ /path/to/backup/kubernetes/$(date +%Y-%m-%d)/prisme-resources.yaml
2
Back Up Helm Values
Save your Helm chart values for each release:
Copy
Ask AI
# Get values for each Helm releasehelm get values prisme-core -n prisme-system -o yaml > \ /path/to/backup/helm/$(date +%Y-%m-%d)/prisme-core-values.yamlhelm get values prisme-securechat -n prisme-system -o yaml > \ /path/to/backup/helm/$(date +%Y-%m-%d)/prisme-securechat-values.yaml# Repeat for each product module
3
Back Up Terraform State
If using Terraform, back up your state files:
Copy
Ask AI
# If using local statecp terraform.tfstate terraform.tfstate.backupcp -r terraform.tfstate.d /path/to/backup/terraform/$(date +%Y-%m-%d)# If using remote state (recommended), ensure your remote backend has proper backup
Using remote state in Terraform (like S3 with versioning or Terraform Cloud) provides built-in backup capabilities.
# List available snapshotscurl -X GET "localhost:9200/_snapshot/backup_repository/_all"# Restore from snapshotcurl -X POST "localhost:9200/_snapshot/backup_repository/snapshot_YYYYMMDD/_restore" -H "Content-Type: application/json" -d'{ "indices": "*", "ignore_unavailable": true, "include_global_state": true}'# Check restore statuscurl -X GET "localhost:9200/_recovery?human"
# If using persistent volume in Kuberneteskubectl cp /path/to/backup/redis/dump_YYYYMMDD.rdb \ prisme-system/redis-0:/data/dump.rdb# For standalone Rediscp /path/to/backup/redis/dump_YYYYMMDD.rdb /path/to/redis/data/dump.rdb
3
Restart Redis
Start Redis service with the restored data:
Copy
Ask AI
# For Kuberneteskubectl scale statefulset -n prisme-system redis --replicas=1# For standalone Redissystemctl start redis# Verify Redis is running with restored dataredis-cli -h redis-host -a password info keyspace
1
Prepare for Restore
Consider the impact of restoration on your application:
Copy
Ask AI
# Scale down services that interact with object storagekubectl scale deployment -n prisme-system --replicas=0 \ prisme-document-processor prisme-file-handler
2
Restore S3 Data
Sync data from your backup location:
Copy
Ask AI
# From backup bucketaws s3 sync s3://your-backup-bucket s3://your-prisme-bucket# Or from local backupaws s3 sync /path/to/backup/s3-data s3://your-prisme-bucket
If using versioning, you can restore specific versions of objects:
Copy
Ask AI
# List versions of a specific objectaws s3api list-object-versions --bucket your-prisme-bucket --prefix path/to/object# Restore specific versionaws s3api copy-object --copy-source your-prisme-bucket/path/to/object?versionId=VERSION_ID \ --bucket your-prisme-bucket --key path/to/object
3
Verify Restoration
Check that files have been properly restored:
Copy
Ask AI
# List objects in bucketaws s3 ls s3://your-prisme-bucket --recursive | head# Count objectsaws s3 ls s3://your-prisme-bucket --recursive | wc -l
# First, clean up the namespace if necessary# WARNING: This will delete all resources! Use with caution.# kubectl delete namespace prisme-system# kubectl create namespace prisme-system# Apply backed-up resourceskubectl apply -f /path/to/backup/kubernetes/YYYY-MM-DD/prisme-resources.yaml
Be cautious when restoring resources. Consider restoring specific resource types instead of everything at once:
Copy
Ask AI
# Restore only ConfigMaps and Secrets firstkubectl apply -f /path/to/backup/kubernetes/YYYY-MM-DD/configmaps.yamlkubectl apply -f /path/to/backup/kubernetes/YYYY-MM-DD/secrets.yaml# Then restore other resourceskubectl apply -f /path/to/backup/kubernetes/YYYY-MM-DD/deployments.yaml
2
Restore Helm Releases
Use your backed-up values to reinstall or upgrade Helm releases:
# For local statecp /path/to/backup/terraform/YYYY-MM-DD/terraform.tfstate .cp -r /path/to/backup/terraform/YYYY-MM-DD/terraform.tfstate.d .# Verify stateterraform state list
For remote state, follow your backend provider’s restoration process.