Skip to main content

System Maintenance

Keep your Borg UI installation healthy with regular maintenance tasks.

Database Migrations

Borg UI uses an automatic migration system to upgrade the database schema across versions.

How Migrations Work

Automatic execution (from app/database/migrations/__init__.py:12-55):
Migration process:
  1. On startup, Borg UI scans /app/database/migrations/ for numbered migration files
  2. Files are executed in order: 001_*.py, 002_*.py, …, 072_*.py
  3. Each migration is idempotent - safe to run multiple times
  4. Checks for existing columns/tables before adding
  5. Logs success/failure for each migration

Migration Files

As of latest version, 72 migrations are included: Recent migrations:
  • 072_add_mqtt_base_topic.py - MQTT base topic configuration
  • 070_add_source_size_timeout.py - Source size calculation timeout
  • 069_add_bypass_lock_on_list.py - Bypass lock for list operations
  • 066_add_ssh_path_prefix.py - SSH path prefix support
  • 061_add_bypass_lock_on_info.py - Bypass lock for info operations
  • 053_add_operation_timeouts.py - Configurable operation timeouts
  • 040_add_cache_settings.py - Redis cache configuration
Example migration (053_add_operation_timeouts.py:13-68):

Monitoring Migrations

View migration logs on startup:
Check for migration failures:

Manual Migration Rollback

Rollback is not supported by default. Migrations are designed to be forward-only. Manual intervention required for rollback.
If you must rollback:
  1. Restore from database backup:
  1. Manual SQL rollback (advanced):
SQLite does not support DROP COLUMN. You must recreate the table without the column and migrate data.

Database Backups

Automatic Backups

Backup before updates:

Manual Backups

Online backup (recommended):
Offline backup (safest):

Scheduled Backups

Using cron:
Using systemd timer:

Database Restore

Restore from backup:
Restore specific tables only:

Log Management

Borg UI includes automatic log rotation with configurable retention and size limits.

Log Storage

Log locations:
  • Job logs: /data/logs/backup_job_*.log, /data/logs/restore_job_*.log, etc.
  • Application log: /data/logs/borg-ui.log
  • Docker logs: docker logs borg-web-ui
Log types (from app/services/log_manager.py:32-39):

Automatic Log Rotation

How it works (app/services/log_manager.py:352-432):
  1. Age-based cleanup: Delete logs older than configured days
  2. Size-based cleanup: Delete oldest logs if total size exceeds limit
  3. Protected logs: Running jobs’ logs are never deleted
  4. Combined cleanup: Both age and size limits enforced
Configuration: Via UI (Settings → System → Log Management):
  • Log Retention Days: 7, 14, 30, 60, 90 days (default: 30)
  • Max Total Log Size: 100-5000 MB (default: 500 MB)
Triggered automatically:
  • Before each backup (in backup_service.rotate_logs())
  • Manually via Settings → System → Cleanup Logs

Manual Log Cleanup

View log storage:
Clean old logs:
Clean specific job type:

Log Rotation Configuration

Via database migration (033_add_log_management_settings.py):
Protected logs implementation (app/services/log_manager.py:116-146):
Running job logs are never deleted during cleanup.

Database Maintenance

Optimize Database

VACUUM (reclaim space):
ANALYZE (optimize queries):
Combined maintenance:

Check Database Integrity

Quick check:
Full check (slower):
Check specific table:

Repair Corrupted Database

Database corruption is rare. Always try backup restoration first.
Attempt repair:

Repository Maintenance

Compact Repositories

Purpose: Reclaim space from deleted archives (after prune operations). Via UI:
  1. Go to Repository → Maintenance
  2. Click Compact Repository
  3. Wait for completion (can take hours for large repos)
Via CLI:
When to compact:
  • After pruning archives
  • When repository shows “sparse” disk usage
  • To reclaim significant space
Scheduled compaction:

Check Repositories

Verify repository integrity:
Scheduled checks:

Prune Archives

Configure retention policy: Via UI: Repository → Settings → Prune Policy
  • Keep last 7 daily backups
  • Keep last 4 weekly backups
  • Keep last 12 monthly backups
  • Keep last 7 yearly backups
Manual prune:

System Updates

Update Borg UI

Recommended update process:
Update to specific version:

Rollback After Failed Update

If update fails:

Maintenance Schedule

Daily Tasks

These run automatically:
  • ✅ Log rotation (before each backup)
  • ✅ Scheduled backups (if configured)
  • ✅ Scheduled repository checks (if configured)
No manual intervention required.

Weekly Tasks

Monthly Tasks

  1. Database backup:
  1. Database optimization:
  1. Repository checks:
  1. Review and clean old logs:
  1. Update Borg UI:

Quarterly Tasks

  1. Test disaster recovery:
  1. Audit user accounts:
  1. Review and update schedules:
  1. Performance review:
  1. Security audit:

Maintenance Scripts

All-in-One Maintenance Script

Schedule with cron:

Troubleshooting

Common maintenance issues and fixes

Performance

Database and cache optimization

Security

Database backup encryption

Configuration

Log and backup settings