mirror of
https://github.com/acedanger/shell.git
synced 2025-12-05 22:50:18 -08:00
feat: Implement parallel backup execution with result logging
This commit is contained in:
@@ -457,7 +457,8 @@ backup_service() {
|
||||
|
||||
# Handle Jellyseerr services with specialized backup function
|
||||
if [[ "$service" == jellyseerr_* ]]; then
|
||||
return $(backup_jellyseerr_service "$service")
|
||||
backup_jellyseerr_service "$service"
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Handle special cases for container names
|
||||
@@ -867,6 +868,57 @@ generate_summary_report() {
|
||||
} >> "$MARKDOWN_LOG"
|
||||
}
|
||||
|
||||
# Wrapper function for parallel backup execution
|
||||
backup_service_wrapper() {
|
||||
local service="$1"
|
||||
local results_file="$2"
|
||||
|
||||
# Call the main backup function and capture result
|
||||
if backup_service "$service"; then
|
||||
# Use a lock file to safely write to results file
|
||||
local lock_file="${results_file}.lock"
|
||||
local max_wait=30
|
||||
local wait_count=0
|
||||
|
||||
while [ $wait_count -lt $max_wait ]; do
|
||||
if (set -C; echo $$ > "$lock_file") 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
((wait_count++))
|
||||
done
|
||||
|
||||
if [ $wait_count -lt $max_wait ]; then
|
||||
echo "SUCCESS:$service" >> "$results_file"
|
||||
rm -f "$lock_file"
|
||||
else
|
||||
# Fallback if lock acquisition fails
|
||||
echo "SUCCESS:$service" >> "$results_file"
|
||||
fi
|
||||
else
|
||||
# Use a lock file to safely write to results file
|
||||
local lock_file="${results_file}.lock"
|
||||
local max_wait=30
|
||||
local wait_count=0
|
||||
|
||||
while [ $wait_count -lt $max_wait ]; do
|
||||
if (set -C; echo $$ > "$lock_file") 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
((wait_count++))
|
||||
done
|
||||
|
||||
if [ $wait_count -lt $max_wait ]; then
|
||||
echo "FAILED:$service" >> "$results_file"
|
||||
rm -f "$lock_file"
|
||||
else
|
||||
# Fallback if lock acquisition fails
|
||||
echo "FAILED:$service" >> "$results_file"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Main backup execution function
|
||||
main() {
|
||||
local script_start_time
|
||||
@@ -970,10 +1022,10 @@ main() {
|
||||
# Collect results
|
||||
while IFS= read -r result; do
|
||||
if [[ "$result" == SUCCESS:* ]]; then
|
||||
((success_count++))
|
||||
success_count=$((success_count + 1))
|
||||
backup_results+=("✓ ${result#SUCCESS:}")
|
||||
elif [[ "$result" == FAILED:* ]]; then
|
||||
((failed_count++))
|
||||
failed_count=$((failed_count + 1))
|
||||
backup_results+=("✗ ${result#FAILED:}")
|
||||
fi
|
||||
done < "$temp_results"
|
||||
@@ -991,10 +1043,10 @@ main() {
|
||||
# Run backups sequentially
|
||||
for service in "${!MEDIA_SERVICES[@]}"; do
|
||||
if backup_service "$service"; then
|
||||
((success_count++))
|
||||
success_count=$((success_count + 1))
|
||||
backup_results+=("✓ $service")
|
||||
else
|
||||
((failed_count++))
|
||||
failed_count=$((failed_count + 1))
|
||||
backup_results+=("✗ $service")
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user