Backup & Recovery
Backup & Recovery
Because NodeStack stores all application state inside a single nodestack_data directory, disaster recovery and backups are straightforward.
Online SQLite Backups
SQLite WAL mode allows backing up the database file safely while the server is actively handling reads and writes:
Using SQLite CLI (.backup)
sqlite3 ./nodestack_data/data.db ".backup './backups/backup-$(date +%Y%m%d%H%M).db'"
Scheduled Automated Backup Script
A sample cron script (backup.sh):
#!/bin/bash
BACKUP_DIR="/backups/nodestack"
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
mkdir -p "$BACKUP_DIR"
# 1. Vacuum into safe snapshot
sqlite3 /var/data/nodestack/data.db "VACUUM INTO '$BACKUP_DIR/data_$TIMESTAMP.db';"
# 2. Archive storage files
tar -czf "$BACKUP_DIR/storage_$TIMESTAMP.tar.gz" -C /var/data/nodestack/storage .
# 3. Keep only last 14 days
find "$BACKUP_DIR" -type f -mtime +14 -delete
Restoring from Backup
- Stop the NodeStack process:
sudo systemctl stop nodestack
- Replace
data.dband restore files instorage/:cp /backups/nodestack/data_20261020.db /var/data/nodestack/data.dbrm -f /var/data/nodestack/data.db-wal /var/data/nodestack/data.db-shm - Restart the service:
sudo systemctl start nodestack