-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to specify target mount point #85
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,7 @@ Options: | |
-r, --remote <address> ip address of a remote machine to backup to | ||
-s, --subvolid <subvlid> subvolume id of the mounted BTRFS subvolume to back up to | ||
-u, --UUID <UUID> UUID of the mounted BTRFS subvolume to back up to | ||
-m, --mountpoint <path> Mount point to be used in case the volume is mounted multiple times | ||
|
||
See 'man snap-sync' for more details. | ||
EOF | ||
|
@@ -138,6 +139,10 @@ while [[ $# -gt 0 ]]; do | |
subvolid_cmdline="$2" | ||
shift 2 | ||
;; | ||
-m|--mountpoint) | ||
mountpoint_cmdline="$2" | ||
shift 2 | ||
;; | ||
-n|--noconfirm) | ||
noconfirm="yes" | ||
shift | ||
|
@@ -166,6 +171,7 @@ done | |
description=${description:-"latest incremental backup"} | ||
uuid_cmdline=${uuid_cmdline:-"none"} | ||
subvolid_cmdline=${subvolid_cmdline:-"5"} | ||
mountpoint_cmdline=${mountpoint_cmdline:-"none"} | ||
noconfirm=${noconfirm:-"no"} | ||
|
||
if [[ "$uuid_cmdline" != "none" ]]; then | ||
|
@@ -191,13 +197,23 @@ fi | |
|
||
if [[ "$($ssh findmnt -n -v --target / -o FSTYPE)" == "btrfs" ]]; then | ||
EXCLUDE_UUID=$($ssh findmnt -n -v -t btrfs --target / -o UUID) | ||
TARGETS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v $EXCLUDE_UUID | awk '{print $2}') | ||
DETECTED_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}') | ||
else | ||
TARGETS=$($ssh findmnt -n -v -t btrfs -o TARGET --list) | ||
DETECTED_TARGETS=$($ssh findmnt -n -v -t btrfs -o TARGET --list) | ||
UUIDS=$($ssh findmnt -n -v -t btrfs -o UUID --list) | ||
fi | ||
|
||
if [[ "$mountpoint_cmdline" == "none" ]]; then | ||
TARGETS=$DETECTED_TARGETS | ||
else | ||
if grep -q "$mountpoint_cmdline" <<< "$DETECTED_TARGETS" ;then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this single grep is satisfying enough. Or at least it could be improved. I did not test this, but what if detected targets contains |
||
TARGETS=$mountpoint_cmdline | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldnt it make sense to escape the variable here when the path contains spaces? |
||
else | ||
die "The provided mount point is not available" | ||
fi | ||
fi | ||
|
||
declare -a TARGETS_ARRAY | ||
declare -a UUIDS_ARRAY | ||
declare -a SUBVOLIDS_ARRAY | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indention is wrong here