Overview
Regular maintenance ensures your Ubu-Block nodes remain secure, performant, and reliable. This guide covers essential maintenance tasks and best practices.
Database Maintenance
Database Backups
Regularly backup your blockchain and private databases:
Manual Backup
Automated Backup Script
Off-site Backup
# Create backup directory
mkdir -p /backup/ubu-block/ $( date +%Y-%m-%d )
# Backup blockchain database
sqlite3 data/blockchain.db ".backup /backup/ubu-block/$( date +%Y-%m-%d)/blockchain.db"
# Backup private database
sqlite3 data/private.db ".backup /backup/ubu-block/$( date +%Y-%m-%d)/private.db"
# Verify backups
ls -lh /backup/ubu-block/ $( date +%Y-%m-%d ) /
Create /usr/local/bin/backup-ubu-block.sh: #!/bin/bash
BACKUP_DIR = "/backup/ubu-block"
DATE = $( date +%Y-%m-%d )
DATA_DIR = "/opt/ubu-block/data"
RETENTION_DAYS = 30
# Create backup directory
mkdir -p " $BACKUP_DIR / $DATE "
# Backup databases
sqlite3 " $DATA_DIR /blockchain.db" ".backup $BACKUP_DIR / $DATE /blockchain.db"
sqlite3 " $DATA_DIR /private.db" ".backup $BACKUP_DIR / $DATE /private.db"
# Compress backups
cd " $BACKUP_DIR / $DATE "
tar -czf "../ubu-block- $DATE .tar.gz" * .db
cd ..
rm -rf " $DATE "
# Remove old backups
find " $BACKUP_DIR " -name "ubu-block-*.tar.gz" -mtime + $RETENTION_DAYS -delete
echo "Backup completed: $BACKUP_DIR /ubu-block- $DATE .tar.gz"
Schedule with cron: # Daily backup at 2 AM
0 2 * * * /usr/local/bin/backup-ubu-block.sh >> /var/log/ubu-block/backup.log 2>&1
Sync backups to remote storage: # Using rsync to remote server
rsync -avz /backup/ubu-block/ user@backup-server:/backups/ubu-block/
# Using AWS S3
aws s3 sync /backup/ubu-block/ s3://my-bucket/ubu-block-backups/
# Using rclone (supports many providers)
rclone sync /backup/ubu-block/ remote:ubu-block-backups/
Always backup the private.db file securely. It contains private keys and sensitive node data.
Database Optimization
Optimize SQLite databases to maintain performance:
# Optimize blockchain database
sqlite3 data/blockchain.db "VACUUM;"
sqlite3 data/blockchain.db "ANALYZE;"
# Optimize private database
sqlite3 data/private.db "VACUUM;"
sqlite3 data/private.db "ANALYZE;"
What these commands do:
VACUUM: Reclaims unused space and defragments the database
ANALYZE: Updates query optimizer statistics for better performance
Run VACUUM when the database is not actively being used, as it requires exclusive access and can take time for large databases.
Database Integrity Checks
Regularly verify database integrity:
# Check blockchain database
sqlite3 data/blockchain.db "PRAGMA integrity_check;"
# Quick check (faster for large databases)
sqlite3 data/blockchain.db "PRAGMA quick_check;"
# Check foreign key constraints
sqlite3 data/blockchain.db "PRAGMA foreign_key_check;"
Schedule automatic checks:
# Weekly integrity check
0 3 * * 0 sqlite3 /opt/ubu-block/data/blockchain.db "PRAGMA integrity_check;" >> /var/log/ubu-block/integrity.log 2>&1
Log Management
Log Rotation
Manage log file sizes to prevent disk space issues:
systemd Journal
Application Logs
# Check current journal size
sudo journalctl --disk-usage
# Limit journal size to 500MB
sudo journalctl --vacuum-size=500M
# Keep only 30 days of logs
sudo journalctl --vacuum-time=30d
# Configure permanent limits in /etc/systemd/journald.conf
sudo nano /etc/systemd/journald.conf
Add or modify: [Journal]
SystemMaxUse =500M
SystemMaxFileSize =50M
MaxRetentionSec =30day
Restart journald: sudo systemctl restart systemd-journald
If logging to files, configure logrotate: Create /etc/logrotate.d/ubu-block: /var/log/ubu-block/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 0640 ubu-block ubu-block
sharedscripts
postrotate
systemctl reload ubu-submission > /dev/null 2>&1 || true
endscript
}
Test configuration: sudo logrotate -d /etc/logrotate.d/ubu-block
Log Analysis and Cleanup
Periodically review and clean up logs:
# Find and remove old log archives
find /var/log/ubu-block/ -name "*.gz" -mtime +90 -delete
# Archive important logs before deletion
tar -czf /backup/logs- $( date +%Y-%m-%d ) .tar.gz /var/log/ubu-block/ * .log
Software Updates
Updating Ubu-Block
Backup before updating
Always create a backup before updating: /usr/local/bin/backup-ubu-block.sh
Pull latest changes
cd /opt/ubu-block
git fetch origin
git checkout main
git pull origin main
Review changes
Check what changed: git log --oneline -10
git diff HEAD~10 HEAD
Rebuild the application
cargo clean
cargo build --release
Stop the node
sudo systemctl stop ubu-submission
Replace binaries
sudo cp target/release/submission /usr/local/bin/
sudo chmod +x /usr/local/bin/submission
Restart the node
sudo systemctl start ubu-submission
sudo systemctl status ubu-submission
Verify the update
# Check logs for errors
sudo journalctl -u ubu-submission -f
# Validate blockchain
cargo run -- validate
# Test API
curl http://localhost:9091/api/v1/health
System Package Updates
Keep the underlying system updated:
# Ubuntu/Debian
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
# Update Rust toolchain
rustup update stable
Test updates in a staging environment before applying to production nodes.
Security Maintenance
File Permission Audits
Regularly verify file permissions:
# Check critical file permissions
ls -la /opt/ubu-block/data/
ls -la /etc/ubu-block/
# Correct permissions if needed
chmod 700 /opt/ubu-block/data
chmod 600 /opt/ubu-block/data/private.db
chmod 644 /opt/ubu-block/data/blockchain.db
chmod 600 /etc/ubu-block/config.toml
SSH Key Rotation
If managing nodes remotely, rotate SSH keys periodically:
# Generate new SSH key
ssh-keygen -t ed25519 -f ~/.ssh/ubu-block-new
# Add new key to server
ssh-copy-id -i ~/.ssh/ubu-block-new.pub user@server
# Test new key
ssh -i ~/.ssh/ubu-block-new user@server
# Remove old key from server
ssh user@server "sed -i '/old-key-comment/d' ~/.ssh/authorized_keys"
Certificate Management
If using TLS/SSL, monitor certificate expiry:
# Check certificate expiry
openssl x509 -in /etc/ssl/certs/ubu-block.crt -noout -dates
# Renew Let's Encrypt certificate
sudo certbot renew --dry-run
Performance Maintenance
Resource Cleanup
Clean up unnecessary files:
# Clean Rust build artifacts
cd /opt/ubu-block
cargo clean
# Remove old Docker images (if using Docker)
docker system prune -a --filter "until=720h"
# Clean package cache
sudo apt clean # Ubuntu/Debian
Optimize SQLite for your workload:
# Add pragmas to improve performance (use with caution)
sqlite3 data/blockchain.db << EOF
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA cache_size = -64000;
PRAGMA temp_store = MEMORY;
EOF
WAL (Write-Ahead Logging) mode allows concurrent reads and writes, improving performance for multi-user scenarios.
Disaster Recovery Testing
Testing Backups
Regularly test backup restoration:
Create test environment
mkdir -p /tmp/restore-test/data
Restore from backup
tar -xzf /backup/ubu-block/ubu-block-2026-03-04.tar.gz -C /tmp/restore-test/data/
Verify restored data
# Check database integrity
sqlite3 /tmp/restore-test/data/blockchain.db "PRAGMA integrity_check;"
# Verify data
sqlite3 /tmp/restore-test/data/blockchain.db "SELECT COUNT(*) FROM blocks;"
Disaster Recovery Plan
Document your recovery procedures:
Backup locations : Where are backups stored?
Recovery time objective (RTO) : How quickly can you restore service?
Recovery point objective (RPO) : How much data loss is acceptable?
Contact information : Who to notify during an outage?
Restoration steps : Detailed steps to restore from backup
Maintenance Schedule
Recommended maintenance schedule:
Monitor node status and logs
Verify blockchain integrity
Check disk space
Review error logs
Create database backups
Review and analyze performance metrics
Check security logs for anomalies
Test API endpoints
Optimize databases (VACUUM, ANALYZE)
Update system packages
Rotate and archive logs
Review and update documentation
Test disaster recovery procedures
Update Ubu-Block software
Security audit and penetration testing
Review and update disaster recovery plan
Capacity planning and scaling assessment
Maintenance Checklist
Use this checklist for routine maintenance:
## Weekly Maintenance Checklist
- [ ] Verify all nodes are running
- [ ] Create and verify backups
- [ ] Check disk space (>20% free)
- [ ] Review error logs
- [ ] Validate blockchain integrity
- [ ] Check database sizes and growth
- [ ] Monitor resource usage (CPU, memory)
- [ ] Verify peer connections
- [ ] Test API health endpoints
- [ ] Review security logs
## Monthly Maintenance Checklist
- [ ] Optimize databases (VACUUM, ANALYZE)
- [ ] Update system packages
- [ ] Rotate and compress logs
- [ ] Test backup restoration
- [ ] Review performance metrics
- [ ] Update monitoring dashboards
- [ ] Check SSL certificate expiry
- [ ] Document any changes
Automated Maintenance Script
Create a comprehensive maintenance script:
/usr/local/bin/ubu-maintenance.sh
#!/bin/bash
set -e
LOG_FILE = "/var/log/ubu-block/maintenance.log"
DATA_DIR = "/opt/ubu-block/data"
log () {
echo "[$( date '+%Y-%m-%d %H:%M:%S')] $1 " | tee -a " $LOG_FILE "
}
log "Starting maintenance tasks..."
# Backup databases
log "Creating backups..."
/usr/local/bin/backup-ubu-block.sh
# Optimize databases
log "Optimizing databases..."
sqlite3 " $DATA_DIR /blockchain.db" "VACUUM; ANALYZE;"
sqlite3 " $DATA_DIR /private.db" "VACUUM; ANALYZE;"
# Check integrity
log "Checking database integrity..."
sqlite3 " $DATA_DIR /blockchain.db" "PRAGMA integrity_check;" | tee -a " $LOG_FILE "
# Clean old logs
log "Cleaning old logs..."
journalctl --vacuum-time=30d
# Check disk space
log "Checking disk space..."
df -h " $DATA_DIR " | tee -a " $LOG_FILE "
# Validate blockchain
log "Validating blockchain..."
cd /opt/ubu-block && cargo run -- validate 2>&1 | tee -a " $LOG_FILE "
log "Maintenance tasks completed."
Schedule monthly:
0 4 1 * * /usr/local/bin/ubu-maintenance.sh
Next Steps
Monitoring Monitor node health and performance
Troubleshooting Resolve common issues