diff --git a/CHANGELOG.md b/CHANGELOG.md index da06ec6..38886fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,6 +119,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Manual backups always include block device even on non-Sunday - Script version bumped to 1.1.0 for multi-target support +### Added +- **Automatic connection testing at startup** + - All configured targets are automatically tested when script starts + - Quick authentication check (5 second timeout per target) + - Shows connection status: ✓ Connected or ✗ Failed + - Helps identify configuration issues before running backups + - Warns user if any targets have connection problems + - Runs in subshell to avoid environment pollution + ### Changed - **Improved menu flow for viewing target details** - "View target details" moved from main menu option 6 to sub-menu under "List all backup targets" diff --git a/pbs-client-installer.sh b/pbs-client-installer.sh index 1e3a596..2cb2708 100755 --- a/pbs-client-installer.sh +++ b/pbs-client-installer.sh @@ -123,6 +123,58 @@ resolve_target_input() { return 0 } +# Quick authentication test for a single target (minimal output) +quick_test_target() { + local target_name="$1" + local config_file="$(get_target_config_path "$target_name")" + + if [ ! -f "$config_file" ]; then + return 1 + fi + + # Source config in subshell to avoid polluting environment + ( + source "$config_file" + export PBS_REPOSITORY + export PBS_PASSWORD + + # Quick auth test - just try to login + echo "y" | timeout 5 proxmox-backup-client login >/dev/null 2>&1 + ) + return $? +} + +# Test all configured targets and display status +test_all_targets() { + if ! list_targets >/dev/null 2>&1; then + return 0 + fi + + echo + echo "════════════════════════════════════════" + echo " Testing Backup Target Connections" + echo "════════════════════════════════════════" + echo + + local all_ok=true + while IFS= read -r target; do + printf " %-20s " "$target:" + + if quick_test_target "$target"; then + echo "✓ Connected" + else + echo "✗ Failed" + all_ok=false + fi + done < <(list_targets) + + echo + if [ "$all_ok" = false ]; then + warn "Some targets failed connection test" + info "Use option 3 (Edit target) to fix connection issues" + fi +} + migrate_legacy_config() { # Check if old single-target config exists if [ -f "$CONFIG_DIR/config" ] && [ ! -d "$TARGETS_DIR" ]; then @@ -1965,6 +2017,7 @@ main() { # Check if any targets exist if list_targets >/dev/null 2>&1; then show_targets_list + test_all_targets # Main menu loop while true; do