diff --git a/bin/snap-sync b/bin/snap-sync index 91a5457..1bb472e 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -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 remote port; wsed with '--remote'. -q, --quiet do not send notifications; instead print them. -r, --remote
ip address of a remote machine to backup to @@ -105,6 +106,7 @@ EOF ssh="" sudo=0 +mount_cmdline="" while [[ $# -gt 0 ]]; do key="$1" case $key in @@ -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 @@ -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." @@ -257,7 +274,7 @@ fi if [[ "$disk" == -1 ]]; then if [[ "$disk_count" == 0 && "$uuid_cmdline" != "none" ]]; then - error "A device with UUID $uuid_cmdline and subvolid $subvolid_cmdline was not found to be mounted, or it is not a BTRFS device." + error "A device with UUID $uuid_cmdline and subvolid $subvolid_cmdline was not found to be mounted, or it is not a BTRFS device, or you specified an invalid mount point" fi if [[ -z $ssh ]]; then printf "Select a mounted BTRFS device on your local machine to backup to.\nFor more options, exit and run '$name -h'.\n" diff --git a/man8/snap-sync.8 b/man8/snap-sync.8 index 4018891..6f67de1 100644 --- a/man8/snap-sync.8 +++ b/man8/snap-sync.8 @@ -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] @@ -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