Skip to main content

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:
# 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)/
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:
# 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

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

1

Backup before updating

Always create a backup before updating:
/usr/local/bin/backup-ubu-block.sh
2

Pull latest changes

cd /opt/ubu-block
git fetch origin
git checkout main
git pull origin main
3

Review changes

Check what changed:
git log --oneline -10
git diff HEAD~10 HEAD
4

Rebuild the application

cargo clean
cargo build --release
5

Stop the node

sudo systemctl stop ubu-submission
6

Replace binaries

sudo cp target/release/submission /usr/local/bin/
sudo chmod +x /usr/local/bin/submission
7

Restart the node

sudo systemctl start ubu-submission
sudo systemctl status ubu-submission
8

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

Performance Tuning

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:
1

Create test environment

mkdir -p /tmp/restore-test/data
2

Restore from backup

tar -xzf /backup/ubu-block/ubu-block-2026-03-04.tar.gz -C /tmp/restore-test/data/
3

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;"
4

Cleanup

rm -rf /tmp/restore-test

Disaster Recovery Plan

Document your recovery procedures:
  1. Backup locations: Where are backups stored?
  2. Recovery time objective (RTO): How quickly can you restore service?
  3. Recovery point objective (RPO): How much data loss is acceptable?
  4. Contact information: Who to notify during an outage?
  5. 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

Build docs developers (and LLMs) love