From: Asish Kumar Date: Thu, 14 May 2026 03:52:20 +0000 (+0530) Subject: Skip placeholder creation when source-config has no snapshots X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1132%2Fhead;p=thirdparty%2Fsnapper.git 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 --- 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'