#!/bin/bash # Shared helpers for compose volume operations. # Ephemeral volumes (init-container config) are excluded from backup/restore/size. is_ephemeral_volume_key() { local key=$1 local compose_file=$2 # op-node rollup config volumes [[ "$key" == *_node_config ]] && return 0 if [[ -n "$compose_file" && -f "$compose_file" ]]; then local ephemeral ephemeral=$(yaml2json "$compose_file" 2>/dev/null | jq -r '.["x-ephemeral-volumes"] // [] | .[]' 2>/dev/null) while IFS= read -r vol; do [[ -z "$vol" ]] && continue [[ "$key" == "$vol" ]] && return 0 done <<< "$ephemeral" fi return 1 } get_volume_keys() { local compose_file=$1 yaml2json "$compose_file" 2>/dev/null | jq -r '.volumes | keys[]' 2>/dev/null } get_persistent_volume_keys() { local compose_file=$1 local key while IFS= read -r key; do [[ -z "$key" ]] && continue if ! is_ephemeral_volume_key "$key" "$compose_file"; then echo "$key" fi done < <(get_volume_keys "$compose_file") }