scripts/snapper-sync derives the highest snapshot number for each source-config from snbk list and then creates a placeholder named after that number under <subvolume>/.snapshots/. When no snapshots match, jq prints the literal string "null" for the existing max_by query, which previously led to a .snapshots/null directory.
Keep the original jq query unchanged and skip placeholder creation when max_num is "null". Also quote "$outputs" on the line that feeds the JSON list into jq, preserving the existing shellcheck SC2086 fix.
Fixes #1131
if outputs=$(snbk --machine-readable json list); then
snapshots=$(
- echo $outputs |
+ echo "$outputs" |
jq --argjson config_mapping "$config_mapping" '
.snapshots | . |= map(. + {config: $config_mapping[.name]})
'
jq -r "[.[] | select(.config == \"$source_config\")] | max_by(.number) | .number"
)
+ # Nothing to synchronize for this source-config (e.g. no snapshots have been transferred
+ # and the source has none either). Skip to avoid creating a literal '.snapshots/null'
+ # placeholder directory.
+ if [ "$max_num" = "null" ]; then
+ echo "No snapshots found for source-config '$source_config'; skipping."
+ continue
+ fi
+
# Query the source subvolume path
subvol_path=$(
snapper --machine-readable json -c "$source_config" get-config | jq -r '.SUBVOLUME'