Regular maintenance ensures FeedForward runs smoothly, securely, and efficiently. This guide covers backup procedures, monitoring setup, performance optimization, and routine maintenance tasks.
FeedForward uses a comprehensive backup strategy:
Backup Components:
Database: Full SQLite database files
Configuration: Environment variables and settings
Uploads: Temporary student submissions (if retained)
Logs: System and audit logs
Backup Schedule:
Database: Daily at 2:00 AM
Configuration: On change + weekly
Logs: Weekly rotation
Full System: Weekly
Backup Configuration:
Enabled: Yes
Schedule: "0 2 * * *" (2 AM daily)
Retention Days: 30
Storage Location:
Type: Local Directory
Path: /backups/feedforward/
Compression:
Enable: Yes
Type: gzip
Level: 6
Encryption:
Enable: Yes (recommended)
Method: AES-256
Key Location: /secure/backup.key
The automated backup script (tools/backup.py) performs:
# Run manually
python tools/backup.py
# Or via cron
0 2 * * * /path/to/venv/bin/python /path/to/tools/backup.py
Stop the FeedForward service:
bash
systemctl stop feedforward
Create backup directory:
bash
mkdir -p /backups/feedforward/$(date +%Y%m%d)
Backup database:
bash
cp data/feedforward.db /backups/feedforward/$(date +%Y%m%d)/
Backup configuration:
bash
cp .env /backups/feedforward/$(date +%Y%m%d)/
cp -r config/ /backups/feedforward/$(date +%Y%m%d)/
Create archive:
bash
tar -czf /backups/feedforward/backup-$(date +%Y%m%d).tar.gz \
/backups/feedforward/$(date +%Y%m%d)/
Restart service:
bash
systemctl start feedforward
Monthly verification:
bash
python tools/verify_backup.py /path/to/backup.tar.gz
Restore test: - Use test environment - Restore latest backup - Verify data integrity - Test application functions
Set up alerts for backup failures:
Stop FeedForward:
bash
systemctl stop feedforward
Backup current database:
bash
mv data/feedforward.db data/feedforward.db.old
Restore from backup:
bash
cp /backups/feedforward/backup.db data/feedforward.db
Verify permissions:
bash
chown feedforward:feedforward data/feedforward.db
chmod 644 data/feedforward.db
Start service:
bash
systemctl start feedforward
Check Interval: 5 minutes Timeout: 30 seconds Retries: 3 ```
bash
# Using systemd
systemctl enable feedforward-monitor
systemctl start feedforward-monitorRun comprehensive health check:
python tools/health_check.py --verbose
# Output:
✓ Database: Connected (15.2 MB)
✓ Email: SMTP connection active
✓ AI Providers:
✓ OpenAI: Active (1,234 calls today)
✓ Anthropic: Active (567 calls today)
✓ Storage: 45.6 GB free (78%)
✓ Memory: 2.3 GB used (29%)
✓ CPU: 12% average load
Monitor these performance indicators:
Application Metrics:
- Response time (target: < 200ms)
- Concurrent users
- Request rate
- Error rate (target: < 0.1%)
Database Metrics:
- Query time (target: < 50ms)
- Connection pool usage
- Database size
- Lock contention
AI Metrics:
- API response time
- Token usage
- Cost per feedback
- Model availability
Configure automatic log rotation:
Log Rotation Policy:
Application Logs:
Max Size: 100 MB
Max Age: 30 days
Compress: Yes
Audit Logs:
Max Size: 500 MB
Max Age: 365 days
Archive: Yes
Access Logs:
Max Size: 200 MB
Max Age: 90 days
Compress: Yes
Regular log review tasks:
Daily: Check error logs
bash
grep ERROR logs/feedforward.log | tail -50
Weekly: Analyze patterns
bash
python tools/log_analyzer.py --last-week
Monthly: Generate reports
bash
python tools/generate_log_report.py --month
Vacuum database:
sql
-- Run during low usage
VACUUM;
ANALYZE;
Check integrity:
bash
python tools/db_check.py
Update statistics:
sql
ANALYZE main;
Full optimization:
bash
python tools/db_optimize.py --full
Index maintenance:
sql
-- Rebuild fragmented indexes
REINDEX;
Archive old data:
bash
python tools/archive_old_data.py --months 6
Monitor and manage database size:
Size Thresholds:
Warning: 5 GB
Critical: 8 GB
Maximum: 10 GB
Actions:
At Warning: Alert admin
At Critical: Archive old data
At Maximum: Prevent new submissions
Ensure privacy-compliant data management:
# Verify cleanup python tools/verify_privacy_compliance.py ```
Optimize based on server resources:
Worker Settings:
Workers: (2 × CPU cores) + 1
Threads: 2-4 per worker
Max Requests: 1000
Timeout: 120 seconds
Example (4-core server):
Workers: 9
Threads: 3
Total Capacity: 27 concurrent requests
Enable caching for better performance:
Cache Settings:
Static Files: 1 hour
API Responses: 5 minutes
User Sessions: 24 hours
AI Results: 1 hour
Cache Storage:
Type: Memory (Redis recommended)
Max Size: 1 GB
Eviction: LRU
Identify slow queries:
bash
python tools/slow_query_log.py --threshold 100ms
Add missing indexes:
sql
-- Example: Speed up assignment lookups
CREATE INDEX idx_assignment_course
ON assignments(course_id, status);
Optimize common queries: - Use prepared statements - Batch operations - Limit result sets
Database Pool:
Min Connections: 5
Max Connections: 20
Max Overflow: 10
Timeout: 30 seconds
Recycle: 3600 seconds
Weekly security scan:
bash
python tools/security_scan.py
Dependency updates: ```bash # Check for updates pip list --outdated
# Update safely pip install --upgrade -r requirements.txt ```
Regular access reviews:
Monthly user audit:
bash
python tools/user_audit.py --inactive-days 90
Permission review: - Check admin accounts - Verify instructor limits - Remove unused accounts
API key rotation: - Schedule quarterly rotation - Update documentation - Test after rotation
High Database Growth
# Identify large tables
python tools/db_size_report.py
# Clean up old data
python tools/cleanup_old_data.py --days 180
Performance Degradation
# Run performance diagnostic
python tools/performance_diagnostic.py
# Common fixes:
- Increase worker count
- Add database indexes
- Enable caching
- Optimize queries
Backup Failures
# Check disk space
df -h /backups
# Verify permissions
ls -la /backups/feedforward/
# Test backup manually
python tools/backup.py --verbose
Create maintenance schedule:
# Edit crontab
crontab -e
# Add maintenance tasks
# Daily backup (2 AM)
0 2 * * * /path/to/venv/bin/python /path/to/tools/backup.py
# Weekly optimization (Sunday 3 AM)
0 3 * * 0 /path/to/venv/bin/python /path/to/tools/db_optimize.py
# Monthly report (1st day, 4 AM)
0 4 1 * * /path/to/venv/bin/python /path/to/tools/generate_monthly_report.py
# Privacy cleanup (daily 1 AM)
0 1 * * * /path/to/venv/bin/python /path/to/tools/cleanup_drafts.py
Set up automated monitoring:
Health check monitoring:
yaml
Service: feedforward-monitor
Type: systemd timer
Interval: 5 minutes
Action: Email on failure
Performance alerts:
yaml
Metrics:
CPU > 80%: Warning
Memory > 90%: Critical
Disk > 85%: Warning
Response Time > 500ms: Alert
Document and test recovery procedures:
In case of system failure:
Always perform maintenance during scheduled windows and notify users in advance.
Automate as many maintenance tasks as possible to ensure consistency and reduce manual errors.