mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -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
|
# Handle Jellyseerr services with specialized backup function
|
||||||
if [[ "$service" == jellyseerr_* ]]; then
|
if [[ "$service" == jellyseerr_* ]]; then
|
||||||
return $(backup_jellyseerr_service "$service")
|
backup_jellyseerr_service "$service"
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle special cases for container names
|
# Handle special cases for container names
|
||||||
@@ -867,6 +868,57 @@ generate_summary_report() {
|
|||||||
} >> "$MARKDOWN_LOG"
|
} >> "$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 backup execution function
|
||||||
main() {
|
main() {
|
||||||
local script_start_time
|
local script_start_time
|
||||||
@@ -970,10 +1022,10 @@ main() {
|
|||||||
# Collect results
|
# Collect results
|
||||||
while IFS= read -r result; do
|
while IFS= read -r result; do
|
||||||
if [[ "$result" == SUCCESS:* ]]; then
|
if [[ "$result" == SUCCESS:* ]]; then
|
||||||
((success_count++))
|
success_count=$((success_count + 1))
|
||||||
backup_results+=("✓ ${result#SUCCESS:}")
|
backup_results+=("✓ ${result#SUCCESS:}")
|
||||||
elif [[ "$result" == FAILED:* ]]; then
|
elif [[ "$result" == FAILED:* ]]; then
|
||||||
((failed_count++))
|
failed_count=$((failed_count + 1))
|
||||||
backup_results+=("✗ ${result#FAILED:}")
|
backup_results+=("✗ ${result#FAILED:}")
|
||||||
fi
|
fi
|
||||||
done < "$temp_results"
|
done < "$temp_results"
|
||||||
@@ -991,10 +1043,10 @@ main() {
|
|||||||
# Run backups sequentially
|
# Run backups sequentially
|
||||||
for service in "${!MEDIA_SERVICES[@]}"; do
|
for service in "${!MEDIA_SERVICES[@]}"; do
|
||||||
if backup_service "$service"; then
|
if backup_service "$service"; then
|
||||||
((success_count++))
|
success_count=$((success_count + 1))
|
||||||
backup_results+=("✓ $service")
|
backup_results+=("✓ $service")
|
||||||
else
|
else
|
||||||
((failed_count++))
|
failed_count=$((failed_count + 1))
|
||||||
backup_results+=("✗ $service")
|
backup_results+=("✗ $service")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user