diff --git a/clone-backup.sh b/clone-backup.sh index 3dfe222b..b3ef6f21 100755 --- a/clone-backup.sh +++ b/clone-backup.sh @@ -305,6 +305,10 @@ transfer_backup() { backup_file=$(select_newest_local_backup "$backup_dir" "$volume_name") if [[ -z "$backup_file" ]] || [[ ! -f "$backup_file" ]]; then + if [[ "$volume_name" == *-secrets ]]; then + echo "Note: no backup for secrets volume $volume_name (regenerated at create-node), skipping" + return 2 + fi echo "Warning: No restorable backup file found for $volume_name, skipping" return 1 fi @@ -505,6 +509,10 @@ transfer_backup_ssh() { backup_file=$(select_newest_local_backup "$backup_dir" "$volume_name") if [[ -z "$backup_file" ]] || [[ ! -f "$backup_file" ]]; then + if [[ "$volume_name" == *-secrets ]]; then + echo "Note: no backup for secrets volume $volume_name (regenerated at create-node), skipping" + return 2 + fi echo "Warning: No restorable backup file found for $volume_name, skipping" return 1 fi @@ -629,18 +637,26 @@ main() { echo "----------------------------------------" success_count=0 + skipped_volumes="" failed_volumes="" - + for key in $keys; do # Try nc method first transfer_backup "$key" - - if [[ $? -ne 0 ]]; then + rc=$? + + if [[ $rc -eq 2 ]]; then + # secrets volume with no backup — regenerated at create-node, not a failure + skipped_volumes="$skipped_volumes $key" + elif [[ $rc -ne 0 ]]; then echo "NC transfer failed, trying direct SSH..." transfer_backup_ssh "$key" - - if [[ $? -eq 0 ]]; then + rc=$? + + if [[ $rc -eq 0 ]]; then success_count=$((success_count + 1)) + elif [[ $rc -eq 2 ]]; then + skipped_volumes="$skipped_volumes $key" else failed_volumes="$failed_volumes $key" fi @@ -654,6 +670,7 @@ main() { echo "" echo "Transfer Summary:" echo " Successful: $success_count/$volume_count" + [[ -n "$skipped_volumes" ]] && echo " Skipped (no backup by design):$skipped_volumes" [[ -n "$failed_volumes" ]] && echo " Failed:$failed_volumes" # Restore Network buffer and congestion control settings. @@ -683,7 +700,7 @@ main() { $SSH_CMD -O exit "$DEST_HOST" 2>/dev/null # Exit with appropriate status (cleanup will be handled by trap) - [[ $success_count -eq $volume_count ]] && exit 0 || exit 1 + [[ -z "$failed_volumes" ]] && exit 0 || exit 1 } main "$@"