docs: expand README and documentation for production release

- Update README.md status from 'educational proof-of-concept' to 'production-ready'
- Fix binary size: 286KB -> 3.3MB
- Update test count: 162/35 -> 262/56
- Add sections: benchmarks, Docker, clients, security, config, monitoring, backup, cross-modal queries, troubleshooting
- Expand project structure with all 49 modules and ~14,100 LOC
- Add 10 new docs: performance, deployment, configuration, clients, security, monitoring, backup, crossmodal, troubleshooting, changelog
- Expand docs/en: architecture, baraql, installation, protocol
- Update docs/bg: architecture, installation
- Update docs/index.md with new links
- Update .gitignore for __pycache__, rust/target, nim binaries
This commit is contained in:
2026-05-06 17:19:16 +03:00
parent e1bae0c7a0
commit 8993cdc6f3
20 changed files with 4162 additions and 277 deletions
+191
View File
@@ -0,0 +1,191 @@
# Backup & Recovery
## Online Snapshots
BaraDB supports online snapshots without stopping the server. The snapshot
captures a consistent point-in-time view using MVCC.
### Creating a Snapshot
```nim
import barabadb/core/backup
var bm = newBackupManager()
bm.createSnapshot("/backup/baradb_2025-01-15")
```
### Via CLI
```bash
./build/baradadb --snapshot --output=/backup/snapshot.db
```
### Via HTTP API
```bash
curl -X POST http://localhost:8080/api/backup \
-H "Content-Type: application/json" \
-d '{"destination": "/backup/snapshot.db"}'
```
### Automated Backups
Use cron for scheduled backups:
```bash
# Daily snapshot at 2 AM
0 2 * * * /usr/local/bin/baradadb --snapshot --output=/backup/baradb_$(date +\%Y\%m\%d).db
# Keep last 7 days
find /backup -name "baradb_*.db" -mtime +7 -delete
```
## Point-in-Time Recovery (PITR)
BaraDB uses the Write-Ahead Log (WAL) for point-in-time recovery.
### WAL Archiving
Enable continuous WAL archiving:
```bash
BARADB_WAL_ARCHIVE_DIR=/backup/wal \
BARADB_WAL_ARCHIVE_INTERVAL_MS=60000 \
./build/baradadb
```
### Recovery from Checkpoint + WAL
```bash
# Restore from snapshot
./build/baradadb --recover \
--checkpoint=/backup/snapshot.db \
--wal-dir=/backup/wal
# Recovery to specific LSN
./build/baradadb --recover \
--checkpoint=/backup/snapshot.db \
--wal-dir=/backup/wal \
--target-lsn=15420
# Recovery to specific time
./build/baradadb --recover \
--checkpoint=/backup/snapshot.db \
--wal-dir=/backup/wal \
--target-time="2025-01-15T10:30:00Z"
```
### Incremental Backups
Incremental backups only copy changed SSTables:
```bash
./build/baradadb --backup-incremental \
--last-backup=/backup/previous \
--output=/backup/incremental_$(date +%Y%m%d)
```
## Replication as Backup
For continuous protection, use streaming replication:
### Primary
```bash
BARADB_REPLICATION_ENABLED=true \
BARADB_REPLICATION_MODE=async \
./build/baradadb
```
### Replica
```bash
BARADB_REPLICATION_ENABLED=true \
BARADB_REPLICATION_PRIMARY=primary:5432 \
./build/baradadb
```
## Disaster Recovery
### Recovery Procedures
#### Scenario 1: Single File Corruption
```bash
# Identify corrupted SSTable from logs
# Restore specific SSTable from backup
cp /backup/sstables/000012.sst ./data/sstables/
# Rebuild index
./build/baradadb --rebuild-index
```
#### Scenario 2: Complete Data Loss
```bash
# 1. Restore latest snapshot
cp /backup/snapshot.db ./data/
# 2. Replay WAL
./build/baradadb --recover --wal-dir=/backup/wal
# 3. Verify
curl http://localhost:8080/health
```
#### Scenario 3: Cluster Node Failure
```bash
# For Raft clusters, simply start a new node
BARADB_RAFT_NODE_ID=newnode \
BARADB_RAFT_PEERS=node1:9001,node2:9001 \
./build/baradadb
# The new node will catch up via Raft log replication
```
## Backup Verification
Always verify backups:
```bash
# Restore to temporary directory
./build/baradadb --recover \
--checkpoint=/backup/snapshot.db \
--data-dir=/tmp/verify_data
# Run consistency check
curl http://localhost:8080/api/admin/check
```
## Storage Requirements
| Backup Type | Size | Frequency | Retention |
|-------------|------|-----------|-----------|
| Full snapshot | ~1× data size | Daily | 7 days |
| Incremental | ~0.1× data size | Hourly | 24 hours |
| WAL archive | ~0.05× data size / day | Continuous | 30 days |
## Best Practices
1. **Test restores regularly** — A backup you can't restore is useless
2. **Store backups offsite** — Use S3, GCS, or Azure Blob
3. **Encrypt backups** — Use `gpg` or OS-level encryption
4. **Monitor backup jobs** — Alert on failed backups
5. **Document RTO/RPO** — Know your recovery time and point objectives
### Cloud Backup Upload
```bash
# Upload to S3
aws s3 cp /backup/snapshot.db s3://my-bucket/baradb/
# Upload to GCS
gsutil cp /backup/snapshot.db gs://my-bucket/baradb/
# Upload to Azure
az storage blob upload \
--container-name backups \
--file /backup/snapshot.db \
--name baradb/snapshot.db
```