Skip to content

Conversation

@martyone
Copy link

No description provided.

$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}')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants