git clone <repository>
cd backup-script
go build -o bin/backup-tui ./cmd/backup-tui# Edit main configuration
nano config/config.ini
# Configure cloud storage (optional)
rclone config# Launch TUI for guided setup
./bin/backup-tui
# Or run backup directly
./bin/backup-tui backup --dry-runThe Text User Interface provides unified access to all backup functions:
./bin/backup-tui- Backup (Stage 1: Local) - Run local backup with restic
- Cloud Sync (Stage 2: Upload) - Sync to cloud storage
- Cloud Restore (Stage 3: Download) - Restore from cloud
- Directory Management - Select which stacks to backup
- Status & Logs - View system status
- Restic Repository - Manage snapshots and repository
- R: Run backup now
- ↑/↓: Navigate menu
- Enter: Select option
- Q: Quit
# Full backup with progress output
./bin/backup-tui backup
# Dry run to test configuration
./bin/backup-tui backup --dry-run
# With custom config file
./bin/backup-tui backup --config /path/to/config.ini
# Help and options
./bin/backup-tui backup --help# Sync to configured remote
./bin/backup-tui sync
# Dry run
./bin/backup-tui sync --dry-run# Restore from configured remote
./bin/backup-tui restore
# Restore to specific path
./bin/backup-tui restore --target /local/restore/path
# Dry run
./bin/backup-tui restore --dry-run# Validate configuration
./bin/backup-tui validate
# Show status
./bin/backup-tui status# Option 1: Interactive TUI
./bin/backup-tui
# Option 2: Headless backup
./bin/backup-tui backup # Stage 1: Local backup
./bin/backup-tui sync # Stage 2: Cloud sync# 1. Verify backup integrity (via TUI)
./bin/backup-tui
# Navigate to: Restic Repository → Check Repository
# 2. Clean old snapshots (via TUI)
# Navigate to: Restic Repository → Prune Repository
# 3. Or use restic directly
restic forget --repo /path/to/repo --keep-daily 7 --keep-weekly 4 --prune# 1. Restore repository from cloud
./bin/backup-tui restore --target /new/repo/path
# 2. Browse available snapshots
restic snapshots --repo /new/repo/path
# 3. Restore specific data
restic restore latest --repo /new/repo/path --target /restore/location- Launch:
./bin/backup-tui - Select Directory Management
- Use Space or Enter to toggle directory selection
- Press A to enable all, N to disable all
- Press S to save changes
# Edit dirlist file directly
nano dirlist
# Example content:
+webapp # Enable webapp backup
+database # Enable database backup
-monitoring # Disable monitoring backupYou can add external paths (outside DOCKER_STACKS_DIR) via the TUI:
- Open Directory Management
- Press X to add external path
- Enter the full path to the directory
- Toggle enabled/disabled as needed
The system automatically discovers Docker compose directories in your DOCKER_STACKS_DIR and allows you to enable/disable each one. New directories are disabled by default.
The TUI displays real-time progress during backup operations. For headless mode:
# Run with output to log file
./bin/backup-tui backup 2>&1 | tee backup.log
# View logs via TUI
./bin/backup-tui
# Navigate to: Status & Logs# Quick status check
./bin/backup-tui status
# Via TUI
./bin/backup-tui
# Navigate to: Status & Logs
# Verify last backup with restic
restic snapshots --repo /path/to/repo | tail -5# Daily backup at 2 AM
0 2 * * * /path/to/backup-script/bin/backup-tui backup >> /var/log/backup.log 2>&1
# Weekly cloud sync on Sundays at 3 AM
0 3 * * 0 /path/to/backup-script/bin/backup-tui sync >> /var/log/backup.log 2>&1# /etc/systemd/system/docker-backup.service
[Unit]
Description=Docker Stack Backup
After=docker.service
[Service]
Type=oneshot
User=backup
ExecStart=/path/to/backup-script/bin/backup-tui backup# /etc/systemd/system/docker-backup.timer
[Unit]
Description=Daily Docker Backup
Requires=docker-backup.service
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target# Test configuration
./bin/backup-tui backup --dry-run
# Validate config file
./bin/backup-tui validate
# Check restic repository
restic check --repo /path/to/repo
# Verify rclone connectivity
rclone lsd remote:If containers fail to stop or start:
# Check container status manually
docker compose -f /path/to/stack/docker-compose.yml ps
# Force stop containers
docker compose -f /path/to/stack/docker-compose.yml down --timeout 10
# Restart containers manually
docker compose -f /path/to/stack/docker-compose.yml up -dThe backup system uses docker compose down/up -d (not stop/start) for more reliable container management. If a timeout occurs, the entire process group is killed to prevent hung processes.
Corrupted local repository:
./bin/backup-tui restore --target /new/repo/pathLost configuration:
cp config/config.ini.template config/config.ini
# Edit with your settingsMissing directories:
# The system auto-discovers directories on startup
# Use the TUI to enable/disable as needed
./bin/backup-tui
# Navigate to: Directory Management- Use SSD storage for restic repository
- Configure appropriate timeouts in config.ini
- Schedule backups during low-usage periods
- Use incremental backups (restic default behavior)
- Monitor DOCKER_TIMEOUT - increase if containers are slow to stop
- Encrypt restic repository with strong password
- Secure configuration files (chmod 600 config/config.ini)
- Use rclone encryption for sensitive cloud data
- Rotate backup passwords regularly
- Use password file instead of plaintext in config