5.0 KiB
Executable File
Docker Tools - Bash Scripts
This directory contains enhanced bash scripts that match the functionality of the Go version (docwell.go). All scripts are version 2.6.2 and share a common library.
Architecture
All scripts source lib/common.sh, which provides:
- Color output with
NO_COLORsupport - Spinner/progress animations (braille frames)
- Unified logging (
log_info,log_warn,log_error,log_success,log_header) - Config file loading from
~/.config/docwell/config - Compose file detection, stack discovery, validation
- Cleanup traps (signal handling for Ctrl+C)
- Dry-run wrapper (
run_or_dry) - Bounded parallel execution
- SSH helpers
Note
:
docker-stack.shanddocker-update.shhave been combined intodocker-manager.sh. The old scripts are kept for backward compatibility butdocker-manager.shis recommended for new usage.
Scripts Overview
docker-backup.sh
Backup Docker stacks with compression.
Usage:
./docker-backup.sh --list # List stacks
./docker-backup.sh --all # Backup all stacks
./docker-backup.sh --stack myapp # Backup specific stack
./docker-backup.sh --all --quiet --yes # Non-interactive backup
./docker-backup.sh --all --dry-run # Preview without executing
docker-cleanup.sh
Clean up Docker resources (containers, images, volumes, networks, build cache).
Usage:
./docker-cleanup.sh --containers # Remove stopped containers
./docker-cleanup.sh --all --yes # Run all cleanups
./docker-cleanup.sh --images --volumes # Remove images and volumes
./docker-cleanup.sh --all --dry-run # Preview cleanup
docker-manager.sh
Combined stack management and update functionality.
Usage:
./docker-manager.sh --list # List all stacks
./docker-manager.sh --start myapp # Start a stack
./docker-manager.sh --stop myapp # Stop a stack
./docker-manager.sh --check # Check for updates
./docker-manager.sh --update-all # Update all stacks
./docker-manager.sh --update myapp # Update specific stack
./docker-manager.sh --auto --yes # Auto-update all stacks
docker-migrate.sh
Migrate Docker services between servers.
Usage:
./docker-migrate.sh myapp --dest user@remote-host
./docker-migrate.sh --service myapp --dest user@remote --method rsync
./docker-migrate.sh --service myapp --dest remote --bwlimit 50 --retries 5
./docker-migrate.sh --service myapp --dest remote --dry-run
docker-auto-migrate.sh
Migrate ALL stacks to a destination host.
Usage:
./docker-auto-migrate.sh --dest 10.0.0.2 --dest-user admin
./docker-auto-migrate.sh --dest remote-host --method rsync --dry-run
Common Options
All scripts support:
--version— Show version information--help, -h— Show help message--quiet, -q— Suppress non-error output--yes, -y— Auto-confirm all prompts--dry-run— Preview without executing--install-deps— Auto-install missing dependencies (requires root)--log FILE— Custom log file path
Configuration
Config File
Scripts load settings from ~/.config/docwell/config (same as Go version):
StacksDir="/opt/stacks"
BackupBase="/storage/backups/docker-myhost"
LogFile="/tmp/docwell/docwell.log"
OldHost="10.0.0.10"
OldPort="22"
OldUser="admin"
BandwidthMB="50"
TransferRetries="3"
Environment Variables
Config file values can be overridden by environment variables:
STACKS_DIR— Stacks directory (default:/opt/stacks)BACKUP_BASE— Backup base directory (default:/storage/backups/docker-$HOSTNAME)LOG_FILE— Log file path (default:/tmp/docwell/docwell.log)NO_COLOR— Disable color output when set
Migration-specific:
OLD_HOST,OLD_PORT,OLD_USER— Source server defaultsNEW_HOST,NEW_PORT,NEW_USER— Destination server defaults
Comparison with Go Version
| Feature | Bash | Go |
|---|---|---|
| CLI Flags | ✅ | ✅ |
| Interactive Mode | ✅ | ✅ |
| Spinner/Progress | ✅ | ✅ |
| Config File | ✅ | ✅ |
| Dry-Run | ✅ | ✅ |
| Signal Handling | ✅ | ✅ |
| Transfer Methods | ✅ rsync, tar, rclone | ✅ rsync, tar, rclone |
| Parallel Operations | ✅ Bounded | ✅ Full |
| Post-Migration Verify | ✅ | ✅ |
| Bandwidth Limiting | ✅ | ✅ |
| NO_COLOR Support | ✅ | ❌ |
Examples
Automated Backup (cron)
0 2 * * * /usr/local/bin/docker-backup.sh --all --quiet --yes
Weekly Cleanup (cron)
0 2 * * 0 /usr/local/bin/docker-cleanup.sh --all --yes --quiet
Update Check Script
#!/bin/bash
/usr/local/bin/docker-manager.sh --check --quiet
Notes
- All scripts require Docker and Docker Compose
- Some operations may require root or sudo
- Scripts use
set -euo pipefailfor strict error handling - Color output disabled when
NO_COLOR=1is set or stdout is not a terminal
See Also
- Go version:
../go/docwell.go - Shared library:
lib/common.sh - Test stack:
../test-stack/