From 05a79e2030f0382815f53a74eed5134f3a0e4c09 Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Thu, 14 May 2026 09:22:20 +0530 Subject: [PATCH] Skip placeholder creation when source-config has no snapshots 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 /.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 --- scripts/snapper-sync | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/snapper-sync b/scripts/snapper-sync index b49d07be..52613918 100755 --- a/scripts/snapper-sync +++ b/scripts/snapper-sync @@ -25,7 +25,7 @@ config_mapping=$( 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]}) ' @@ -47,6 +47,14 @@ echo "$config_mapping" | jq -r 'keys[]' | while read -r backup_config; do 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' -- 2.47.3