volume-utils: per-volume-kind restorable floor (_config tars are legitimately tiny)
The 1MB near-empty guard (added for purged-volume zstd stubs) rejected every legitimate _config volume archive (cronos: 68KB), so any node whose registry entry includes a _config volume reported Restorable: 0 despite healthy multi-GB data backups (cronos had three; 14 registry entries carry _config volumes). _config archives now pass at >=4KB; data volumes keep the 1MB floor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,17 @@
|
|||||||
# zstd headers from purged/missing volumes must not win sort|tail newest selection).
|
# zstd headers from purged/missing volumes must not win sort|tail newest selection).
|
||||||
MIN_RESTORABLE_BACKUP_BYTES=$((1024 * 1024))
|
MIN_RESTORABLE_BACKUP_BYTES=$((1024 * 1024))
|
||||||
|
|
||||||
|
# Config volumes hold a handful of small files: a legitimate config archive can sit
|
||||||
|
# far below the 1MB data floor (cronos: 68KB) while a purged-volume stub is a bare
|
||||||
|
# zstd header (<4KB). A flat 1MB floor made every node with a _config volume in its
|
||||||
|
# registry entry report "Restorable: 0" despite healthy multi-GB data backups.
|
||||||
|
min_restorable_bytes_for() {
|
||||||
|
case "$(basename "$1")" in
|
||||||
|
*_config-*.tar.zst) echo 4096 ;;
|
||||||
|
*) echo "$MIN_RESTORABLE_BACKUP_BYTES" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
RPC_ENV_FILE="/root/rpc/.env"
|
RPC_ENV_FILE="/root/rpc/.env"
|
||||||
|
|
||||||
backup_archive_size_bytes() {
|
backup_archive_size_bytes() {
|
||||||
@@ -19,7 +30,7 @@ is_restorable_backup_archive() {
|
|||||||
local size
|
local size
|
||||||
[[ -f "$file" ]] || return 1
|
[[ -f "$file" ]] || return 1
|
||||||
size=$(backup_archive_size_bytes "$file")
|
size=$(backup_archive_size_bytes "$file")
|
||||||
[[ "$size" =~ ^[0-9]+$ ]] && (( size >= MIN_RESTORABLE_BACKUP_BYTES ))
|
[[ "$size" =~ ^[0-9]+$ ]] && (( size >= $(min_restorable_bytes_for "$file") ))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pick the lexicographically newest backup that is not near-empty (<1MB). Prints one
|
# Pick the lexicographically newest backup that is not near-empty (<1MB). Prints one
|
||||||
@@ -42,7 +53,7 @@ select_newest_local_backup() {
|
|||||||
|
|
||||||
for f in "${files[@]}"; do
|
for f in "${files[@]}"; do
|
||||||
size=$(backup_archive_size_bytes "$f")
|
size=$(backup_archive_size_bytes "$f")
|
||||||
if [[ ! "$size" =~ ^[0-9]+$ ]] || (( size < MIN_RESTORABLE_BACKUP_BYTES )); then
|
if [[ ! "$size" =~ ^[0-9]+$ ]] || (( size < $(min_restorable_bytes_for "$f") )); then
|
||||||
echo "skip near-empty backup artifact: $(basename "$f") (${size:-0} bytes)" >&2
|
echo "skip near-empty backup artifact: $(basename "$f") (${size:-0} bytes)" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -83,7 +94,7 @@ select_newest_remote_backup_from_list() {
|
|||||||
[[ "$f" == "${volume_name}-"* ]] || continue
|
[[ "$f" == "${volume_name}-"* ]] || continue
|
||||||
[[ "$f" == *.tar.zst ]] || continue
|
[[ "$f" == *.tar.zst ]] || continue
|
||||||
size=$(remote_backup_archive_size_bytes "$remote_source" "$f")
|
size=$(remote_backup_archive_size_bytes "$remote_source" "$f")
|
||||||
if [[ -z "$size" || ! "$size" =~ ^[0-9]+$ ]] || (( size < MIN_RESTORABLE_BACKUP_BYTES )); then
|
if [[ -z "$size" || ! "$size" =~ ^[0-9]+$ ]] || (( size < $(min_restorable_bytes_for "$f") )); then
|
||||||
echo "skip near-empty backup artifact: $f (${size:-unknown} bytes)" >&2
|
echo "skip near-empty backup artifact: $f (${size:-unknown} bytes)" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user