Skip to content

Commit

Permalink
Add -m option to manually specify mount point
Browse files Browse the repository at this point in the history
Fixes #71
  • Loading branch information
wesbarnett committed Jan 30, 2021
1 parent 276e177 commit 7b5e4aa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
33 changes: 25 additions & 8 deletions bin/snap-sync
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Options:
-n, --noconfirm do not ask for confirmation
-k, --keepold keep old incremental snapshots instead of deleting them
after backup is performed
-m, --mountpoint optionally specify where subvolume is mounted if mounted in multiple locations
-p, --port <port> remote port; wsed with '--remote'.
-q, --quiet do not send notifications; instead print them.
-r, --remote <address> ip address of a remote machine to backup to
Expand All @@ -105,6 +106,7 @@ EOF

ssh=""
sudo=0
mount_cmdline=""
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
Expand All @@ -124,6 +126,10 @@ while [[ $# -gt 0 ]]; do
subvolid_cmdline="$2"
shift 2
;;
-m|--mountpoint)
mount_cmdline="$2"
shift 2
;;
-k|--keepold)
keep="yes"
shift
Expand Down Expand Up @@ -237,14 +243,25 @@ done
i=0
disk=-1
disk_count=0
for x in $UUIDS; do
UUIDS_ARRAY[$i]=$x
if [[ "$x" == "$uuid_cmdline" && ${SUBVOLIDS_ARRAY[$((i))]} == "$subvolid_cmdline" ]]; then
disk=$i
disk_count=$(($disk_count+1))
fi
i=$((i+1))
done
if [[ -z "$mount_cmdline" ]]; then
for x in $UUIDS; do
UUIDS_ARRAY[$i]=$x
if [[ "$x" == "$uuid_cmdline" && ${SUBVOLIDS_ARRAY[$((i))]} == "$subvolid_cmdline" ]]; then
disk=$i
disk_count=$(($disk_count+1))
fi
i=$((i+1))
done
else
for x in $UUIDS; do
UUIDS_ARRAY[$i]=$x
if [[ "$x" == "$uuid_cmdline" && ${SUBVOLIDS_ARRAY[$((i))]} == "$subvolid_cmdline" && ${TARGETS_ARRAY[$((i))]} == "$mount_cmdline"]]; then
disk=$i
disk_count=$(($disk_count+1))
fi
i=$((i+1))
done
fi

if [[ "${#UUIDS_ARRAY[$@]}" -eq 0 ]]; then
die "No external btrfs subvolumes found to backup to. Run '$name -h' for more options."
Expand Down
11 changes: 10 additions & 1 deletion man8/snap-sync.8
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ snap-sync \- send incremental btrfs snapshots, keeping track of them with snappe
[\fB-p\fR \fIport\fR]
[\fB--sudo\fR]
[\fB-s\fR \fIsubvolid\fR]
[\fB-m\fR \fImountpoint\fR]
[\fB-u\fR \fIUUID\fR]
[\fB-k\fR]
[\fB-q\fR]
Expand Down Expand Up @@ -110,7 +111,15 @@ Specify the subvolume id of the mounted BTRFS subvolume to back up to. Defaults
\fB\-u, \-\-UUID\fR \fIUUID\fR
.RS 4
Specify the UUID of the mounted BTRFS subvolume to back up to. Otherwise will prompt.
If multiple mount points are found with the same UUID and subvolid, will prompt user.
If multiple mount points are found with the same UUID and subvolid, will prompt user,
or user can specify mount point manually with \fB-m\fR.
.RE
.PP

\fB\-m, \-\-mountpoint\fR \fImount point\fR
.RS 4
Specify the mount point of the disk to back up to. Useful if multiple mount points
are used for the same disk.
.RE
.PP

Expand Down

0 comments on commit 7b5e4aa

Please sign in to comment.