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 <file>.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 <vibe@mistral.ai>
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user