Protecting your knowledge graph data.
| Component | Contains | Backup Method |
|---|---|---|
| PostgreSQL | Concepts, relationships, users, config | pg_dump |
| Garage | Original documents | S3-compatible tools |
./operator.sh backupCreates a timestamped SQL dump in the backups directory.
Default backup location: ./backups/
ls -la backups/
# knowledge_graph_2026-01-18_120000.sql# Backup to file
docker exec kg-postgres pg_dump -U admin -d knowledge_graph > backup.sql
# Compressed
docker exec kg-postgres pg_dump -U admin -d knowledge_graph | gzip > backup.sql.gz./operator.sh restore /path/to/backup.sqlOr manually:
# Drop and recreate database
docker exec -i kg-postgres psql -U admin -c "DROP DATABASE IF EXISTS knowledge_graph;"
docker exec -i kg-postgres psql -U admin -c "CREATE DATABASE knowledge_graph;"
# Restore
docker exec -i kg-postgres psql -U admin -d knowledge_graph < backup.sqlGarage uses S3-compatible storage. Back up using standard S3 tools:
# Using AWS CLI (configured for Garage)
aws --endpoint-url http://localhost:3900 s3 sync s3://kg-storage ./garage-backup/
# Using rclone
rclone sync garage:kg-storage ./garage-backup/Or copy the Garage data directory:
cp -r /srv/docker/data/knowledge-graph/garage ./garage-backup/Set up a cron job for regular backups:
# Edit crontab
crontab -e
# Add daily backup at 2 AM
0 2 * * * cd /path/to/knowledge-graph-system && ./operator.sh backupClean up old backups periodically:
# Keep last 7 days
find ./backups -name "*.sql" -mtime +7 -deleteFull recovery procedure:
-
Fresh installation:
git clone https://github.com/aaronsb/knowledge-graph-system.git cd knowledge-graph-system ./operator.sh init --headless ... -
Stop services:
./operator.sh stop
-
Restore database:
./operator.sh restore /path/to/backup.sql
-
Restore Garage data:
cp -r /path/to/garage-backup/* /srv/docker/data/knowledge-graph/garage/ -
Start services:
./operator.sh start
-
Verify:
./operator.sh status kg health
Regularly verify backups work:
# Create test environment
docker run -d --name backup-test -e POSTGRES_PASSWORD=test postgres:16
# Restore to test
docker exec -i backup-test psql -U postgres < backup.sql
# Verify
docker exec backup-test psql -U postgres -d knowledge_graph -c "SELECT COUNT(*) FROM concepts;"
# Cleanup
docker rm -f backup-test