From a43712ae8a198d3fb656896da50f0c9abf1bacc1 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Wed, 31 May 2017 14:22:26 -0400 Subject: [PATCH] Exclude source subvolumes Find out parent mountpoint of /etc/conf.d/snapper, get UUID, and exclude it from list of targets. If no external btrfs subvolumes found, exit. Fixes #28. --- bin/snap-sync | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/snap-sync b/bin/snap-sync index c117a1b..a9d891e 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -141,8 +141,9 @@ else fi fi -TARGETS="$($ssh findmnt -n -v -t btrfs -o TARGET --list)" -UUIDS="$($ssh findmnt -n -v -t btrfs -o UUID --list)" +EXCLUDE_UUID=$(findmnt -n -v -t btrfs --target /etc/conf.d/snapper -o UUID) +TARGETS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v $EXCLUDE_UUID | awk '{print $2}') +UUIDS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v $EXCLUDE_UUID | awk '{print $1}') declare -a TARGETS_ARRAY declare -a UUIDS_ARRAY @@ -165,6 +166,10 @@ for x in $TARGETS; do i=$((i+1)) done +if [[ "${#UUIDS_ARRAY[$@]}" -eq 0 ]]; then + die "No external btrfs subvolumes found to backup to." +fi + if [[ "$disk_count" > 1 ]]; then printf "Multiple mount points were found with UUID $uuid_cmdline.\n" disk="-1"