restore/cleanup: implement static-file -> /slowdisk offload + free it on removal
restore-volumes.sh: pre-create static-file symlinks from the backup's .txt manifest so the immutable ancient/freezer dirs land on /slowdisk (SSD) and extract THROUGH the symlinks via tar --keep-directory-symlink (was --dereference, which clobbered them); hot state stays on the primary disk. Cleans stale /slowdisk targets first (no leak on re-restore). Safe fallbacks: no /slowdisk / no manifest / no static paths -> normal extract. Reth excluded (reth dropped whole-dir static-file symlinks). volume-utils.sh: add delete_slowdisk_targets_for_key() — follows a volume's symlinks and sweeps the rpc_<key>__data_ pattern under /slowdisk (matches delete-volumes.sh). cleanup-volumes.sh: free the /slowdisk static data before docker volume rm (was leaking), and fix the fragile substring used/unused match to an exact name match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,3 +71,30 @@ is_local_backup_url() {
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Delete the /slowdisk static-file offload targets for a single volume key, so removing a
|
||||
# volume also frees the static data behind the symlinks (otherwise it leaks on /slowdisk).
|
||||
# Safe: scoped to the key and to /slowdisk, and only removes dirs matching the
|
||||
# rpc_<key>__data_ naming this repo creates (the same pattern delete-volumes.sh deletes).
|
||||
delete_slowdisk_targets_for_key() {
|
||||
local key=$1
|
||||
[[ -z "$key" ]] && return 0
|
||||
[[ -d /slowdisk ]] || return 0
|
||||
local data_dir="/var/lib/docker/volumes/rpc_${key}/_data"
|
||||
# 1) follow live symlinks in the volume and delete their /slowdisk targets
|
||||
if [[ -d "$data_dir" ]]; then
|
||||
while IFS= read -r -d '' l; do
|
||||
local t; t=$(readlink -f "$l" 2>/dev/null)
|
||||
if [[ -n "$t" && -d "$t" && "$t" == /slowdisk/rpc_${key}__data_* ]]; then
|
||||
echo " rm slowdisk static target $t"; rm -rf "$t"
|
||||
fi
|
||||
done < <(find "$data_dir" -type l -print0 2>/dev/null)
|
||||
fi
|
||||
# 2) sweep any orphaned targets for this key (re-restore / dangling-symlink safety)
|
||||
local t
|
||||
shopt -s nullglob
|
||||
for t in /slowdisk/rpc_${key}__data_*; do
|
||||
[[ -d "$t" ]] && { echo " rm orphan slowdisk static target $t"; rm -rf "$t"; }
|
||||
done
|
||||
shopt -u nullglob
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user