From 6bb0b19f45867db2074ee7e2ed50d7b36895c874 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 17 Jun 2026 16:22:50 +0000 Subject: [PATCH] Harden restore-volumes.sh against silent restore truncation and incomplete-download skips - BUG 1: Add error checking after tar extraction for both LOCAL and REMOTE-CACHE branches - Check exit status of tar -I zstd -xf commands - Print error to stderr and exit non-zero on failure - Prevents silent truncation where corrupt/incomplete backup extracts partial data - Mirrors existing remote-STREAM branch error handling - BUG 2: Fix REMOTE branch to resume incomplete aria2c downloads - Check for presence of .aria2 control file as incomplete signal - aria2c -c continues/resumes download when .aria2 file exists - Only skip download when file exists AND no .aria2 control file remains - aria2 deletes .aria2 sidecar on successful completion, making it a reliable signal - Maintain all existing flags: aria2c -c -Z -x8 -j8 -s8 -d - Preserve reth guard logic and static-file offload behavior unchanged Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- restore-volumes.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/restore-volumes.sh b/restore-volumes.sh index 66e55faa..debae650 100755 --- a/restore-volumes.sh +++ b/restore-volumes.sh @@ -117,17 +117,26 @@ while IFS= read -r key; do echo "No /backup cache: streaming + extracting $newest_file directly" curl --ipv4 -# "${remote_source}${newest_file}" | zstd -d | tar -xf - --keep-directory-symlink -C / if [ $? -ne 0 ]; then - echo "Error processing $newest_file" + echo "Error processing $newest_file" >&2 exit 1 fi else - if [ ! -e "$backup_dir/$(basename "$newest_file")" ]; then + backup_file="$backup_dir/$(basename "$newest_file")" + if [ ! -e "$backup_file" ] || [ -e "${backup_file}.aria2" ]; then aria2c -c -Z -x8 -j8 -s8 -d "$backup_dir" "${remote_source}${newest_file}" fi - tar -I zstd -xf "$backup_dir/$(basename "$newest_file")" --keep-directory-symlink -C / + tar -I zstd -xf "$backup_file" --keep-directory-symlink -C / + if [ $? -ne 0 ]; then + echo "Error processing $newest_file" >&2 + exit 1 + fi fi else tar -I zstd -xf "$newest_file" --keep-directory-symlink -C / + if [ $? -ne 0 ]; then + echo "Error processing $newest_file" >&2 + exit 1 + fi fi echo "Backup '$newest_file' restored" done <<< "$keys"