Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/snap-sync
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ for x in $selected_configs; do
BACKUPDIR="$selected_mnt/$mybackupdir"
$ssh test -d "$BACKUPDIR" || $ssh btrfs subvolume create "$BACKUPDIR"
else
mybackupdir=$(snapper -c "$x" list -t single | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
mybackupdir=$(snapper -c "$x" list -t single | sed 's/│/|/g' | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of replacing the Unicode character, it might be cleaner to not produce it in the first place by executing Snapper with LC_ALL=C:

mybackupdir=$(LC_ALL=C snapper -c "$x" list -t single | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')

(This might be something to consider at other places in the script too where the output of a command line tool is processed by the script.)

Additionally/alternatively, it might make sense to immediately restrict the output to the relevant column; however, this might not be backwards-compatible with older versions of Snapper:

mybackupdir=$(LC_ALL=C snapper -c "$x" list --columns userdata -t single | grep -F "subvolid=$selected_subvolid, uuid=$selected_uuid" | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')

BACKUPDIR="$selected_mnt/$mybackupdir"
$ssh test -d $BACKUPDIR || die "%s is not a directory on %s.\n" "$BACKUPDIR" "$selected_uuid"
fi
Expand Down