diff --git a/backup-node.sh b/backup-node.sh index eab1b320..cd8c8de5 100755 --- a/backup-node.sh +++ b/backup-node.sh @@ -36,15 +36,24 @@ generate_volume_metadata() { # Check each static file path if [[ -f "$static_file_list" ]]; then while IFS= read -r path; do - # Check if the path exists - if [[ -e "$prefix/_data/$path" ]]; then - # Get the size - size=$(du -sL "$prefix/_data/$path" 2>/dev/null | awk '{print $1}') - # Format size in human-readable format - size_formatted=$(echo "$(( size * 1024 ))" | numfmt --to=iec --suffix=B --format="%.2f") - # Write to metadata file - echo "$size_formatted $path" >> "$metadata_file" + [[ -z "$path" ]] && continue + # Match rule (see static-file-path-list.txt): an entry with NO slash is root-level + # only (so `snapshots` won't catch postgres pg_logical/snapshots); an entry WITH a + # slash is a path-suffix, so any prefix matches (network-prefixed nitro freezers, + # nested l2geth geth/geth/...). Record the CONCRETE relative path so restore-volumes + # can recreate the exact static-file -> /slowdisk symlink. + local matches=() m rel + if [[ "$path" == */* ]]; then + while IFS= read -r m; do matches+=("$m"); done < <(find "$prefix/_data" -type d -path "*/$path" 2>/dev/null) + else + [[ -d "$prefix/_data/$path" ]] && matches+=("$prefix/_data/$path") fi + for m in "${matches[@]}"; do + rel="${m#"$prefix/_data/"}" + size=$(du -sL "$m" 2>/dev/null | awk '{print $1}') + size_formatted=$(echo "$(( ${size:-0} * 1024 ))" | numfmt --to=iec --suffix=B --format="%.2f") + echo "$size_formatted $rel" >> "$metadata_file" + done done < "$static_file_list" fi } diff --git a/show-static-file-size.sh b/show-static-file-size.sh index 329517b3..f85430ef 100755 --- a/show-static-file-size.sh +++ b/show-static-file-size.sh @@ -26,16 +26,22 @@ for key in $keys; do # Skip empty lines [[ -z "$path" ]] && continue - # Check if the path exists - if [[ -e "$prefix/_data/$path" ]]; then - # Print the size of the file or directory - size=$(du -sL "$prefix/_data/$path" 2>/dev/null | awk '{print $1}') - static_size=$((static_size + size)) - # Format size in human-readable format - size_formatted=$(echo "$(( size * 1024 ))" | numfmt --to=iec --suffix=B --format="%.2f") - # Print the detected path with size to stderr (one per line) - echo "$size_formatted $prefix/_data/$path" >&2 + # Match rule: an entry with NO slash is root-level only (depth-1 under _data), + # so e.g. `snapshots` won't catch postgres pg_logical/snapshots. An entry WITH a + # slash is a path-suffix, so any prefix matches (network-prefixed nitro freezers + # like arbitrum-one/nitro/l2chaindata/ancient, nested l2geth geth/geth/...). + matches=() + if [[ "$path" == */* ]]; then + while IFS= read -r d; do matches+=("$d"); done < <(find "$prefix/_data" -type d -path "*/$path" 2>/dev/null) + else + [[ -d "$prefix/_data/$path" ]] && matches+=("$prefix/_data/$path") fi + for m in "${matches[@]}"; do + size=$(du -sL "$m" 2>/dev/null | awk '{print $1}') + static_size=$((static_size + ${size:-0})) + size_formatted=$(echo "$(( ${size:-0} * 1024 ))" | numfmt --to=iec --suffix=B --format="%.2f") + echo "$size_formatted $m" >&2 + done done < "$static_file_list" fi done diff --git a/static-file-path-list.txt b/static-file-path-list.txt index ffc78e6f..b0682c77 100644 --- a/static-file-path-list.txt +++ b/static-file-path-list.txt @@ -1,6 +1,7 @@ static_files -chain/nitro/l2chaindata/ancient -data/nitro/l2chaindata/ancient -ancient -geth/chaindata/ancient -bor/chaindata/ancient +snapshots +archiver +chaindata/ancient +lightchaindata/ancient +nitro/l2chaindata/ancient +nitro/classic-msg/ancient