Fix /slowdisk static-file offload: add reth guard and --keep-directory-symlink

- Add RETH GUARD to clone-backup.sh and clone-node.sh: when the config name
  contains 'reth', skip the whole /slowdisk static-file symlink offload and
  extract everything onto the primary disk (equivalent to --no-slowdisk).
  This matches the already-correct restore-volumes.sh behavior.
  Reason: reth refuses to start when its static_files directory is a symlink,
  failing at boot with 'failed to create dir static_files: File exists'.

- Add --keep-directory-symlink to all tar extraction options in both scripts
  for the SLOWDISK path. This allows tar to extract files THROUGH the
  pre-created directory symlinks instead of trying to mkdir over them
  (which fails with 'Cannot mkdir: File exists'). This matches the
  already-correct restore-volumes.sh behavior.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
rob
2026-06-17 16:07:21 +00:00
parent 27d0ea0d28
commit 6ddb18dbc5
2 changed files with 34 additions and 9 deletions

View File

@@ -306,7 +306,7 @@ transfer_backup() {
local backup_basename=$(basename "$backup_file" .tar.zst)
local metadata_file="$backup_dir/${backup_basename}.txt"
local use_slowdisk=false
local tar_extract_opts="-xf - -C /"
local tar_extract_opts="-xf - -C / --keep-directory-symlink"
if [[ -f "$metadata_file" ]] && check_slowdisk_enabled; then
echo "Metadata file found and SLOWDISK mode enabled"
@@ -324,8 +324,9 @@ transfer_backup() {
if setup_slowdisk_structure "$key" "$static_size_kb" "${static_paths[@]}"; then
use_slowdisk=true
# Use --skip-old-files to avoid overwriting existing symlinks/directories
# But we still want to extract files into symlinked directories
tar_extract_opts="-xf - -C / --skip-old-files"
# and --keep-directory-symlink so tar extracts THROUGH the pre-created dir symlinks
# instead of trying to mkdir over them (which fails with 'Cannot mkdir: File exists')
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink"
echo "SLOWDISK structure ready, will extract respecting symlinks"
else
echo "Warning: Failed to setup SLOWDISK structure, falling back to normal extraction"
@@ -494,7 +495,7 @@ transfer_backup_ssh() {
# Check for metadata file and SLOWDISK mode (same logic as transfer_backup)
local backup_basename=$(basename "$backup_file" .tar.zst)
local metadata_file="$backup_dir/${backup_basename}.txt"
local tar_extract_opts="-xf - -C /"
local tar_extract_opts="-xf - -C / --keep-directory-symlink"
if [[ -f "$metadata_file" ]] && check_slowdisk_enabled; then
echo "Metadata file found and SLOWDISK mode enabled"
@@ -508,7 +509,9 @@ transfer_backup_ssh() {
if [[ ${#static_paths[@]} -gt 0 ]] && [[ -n "$static_size_kb" ]]; then
# Setup slowdisk structure on remote
if setup_slowdisk_structure "$key" "$static_size_kb" "${static_paths[@]}"; then
tar_extract_opts="-xf - -C / --skip-old-files"
# and --keep-directory-symlink so tar extracts THROUGH the pre-created dir symlinks
# instead of trying to mkdir over them (which fails with 'Cannot mkdir: File exists')
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink"
echo "SLOWDISK structure ready, will extract respecting symlinks"
else
echo "Warning: Failed to setup SLOWDISK structure, falling back to normal extraction"
@@ -538,6 +541,15 @@ main() {
# Set up cleanup trap
trap cleanup_all_ports EXIT INT TERM
# RETH GUARD: reth refuses to start when its static_files directory is a symlink.
# Match restore-volumes.sh: skip the whole /slowdisk static-file symlink offload
# for reth nodes and extract everything onto the primary disk.
if [[ "$1" == *reth* ]]; then
echo "WARNING: $1 contains 'reth' — static-file symlink offload disabled (reth broke whole-dir symlinks)"
echo " All volumes will be extracted onto the primary disk (equivalent to --no-slowdisk)"
NO_SLOWDISK=true
fi
setup_ssh_multiplex
# Check if backup directory exists

View File

@@ -276,7 +276,7 @@ transfer_volume() {
fi
local folder_size=$(du -sb "$source_folder" 2>/dev/null | awk '{print $1}')
local tar_extract_opts="-xf - -C /"
local tar_extract_opts="-xf - -C / --keep-directory-symlink"
local use_slowdisk=false
# Check for SLOWDISK mode and detect static files
@@ -297,7 +297,9 @@ transfer_volume() {
if setup_slowdisk_structure "$key" "$static_size_kb" "${static_paths[@]}"; then
use_slowdisk=true
# Use --skip-old-files to avoid overwriting existing symlinks/directories
tar_extract_opts="-xf - -C / --skip-old-files"
# and --keep-directory-symlink so tar extracts THROUGH the pre-created dir symlinks
# instead of trying to mkdir over them (which fails with 'Cannot mkdir: File exists')
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink"
echo "SLOWDISK structure ready, will extract respecting symlinks"
else
echo "Warning: Failed to setup SLOWDISK structure, falling back to normal extraction"
@@ -457,7 +459,7 @@ transfer_volume_ssh() {
fi
local folder_size=$(du -sb "$source_folder" 2>/dev/null | awk '{print $1}')
local tar_extract_opts="-xf - -C /"
local tar_extract_opts="-xf - -C / --keep-directory-symlink"
# Check for SLOWDISK mode and detect static files (same logic as transfer_volume)
if check_slowdisk_enabled; then
@@ -475,7 +477,9 @@ transfer_volume_ssh() {
echo "Setting up SLOWDISK structure on target..."
# Setup slowdisk structure on remote
if setup_slowdisk_structure "$key" "$static_size_kb" "${static_paths[@]}"; then
tar_extract_opts="-xf - -C / --skip-old-files"
# and --keep-directory-symlink so tar extracts THROUGH the pre-created dir symlinks
# instead of trying to mkdir over them (which fails with 'Cannot mkdir: File exists')
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink"
echo "SLOWDISK structure ready, will extract respecting symlinks"
else
echo "Warning: Failed to setup SLOWDISK structure, falling back to normal extraction"
@@ -513,6 +517,15 @@ main() {
# Set up cleanup trap
trap cleanup_all_ports EXIT INT TERM
# RETH GUARD: reth refuses to start when its static_files directory is a symlink.
# Match restore-volumes.sh: skip the whole /slowdisk static-file symlink offload
# for reth nodes and extract everything onto the primary disk.
if [[ "$1" == *reth* ]]; then
echo "WARNING: $1 contains 'reth' — static-file symlink offload disabled (reth broke whole-dir symlinks)"
echo " All volumes will be extracted onto the primary disk (equivalent to --no-slowdisk)"
NO_SLOWDISK=true
fi
setup_ssh_multiplex
# the following sysctls are critical for high-latency networks