From: Alan J. Pippin <ajp@pippins.net>
Date: Fri, 1 Dec 2023 17:24:34 +0000 (-0700)
Subject: Fix mountpoint after full fs transfer if needed
X-Git-Url: http://git.pippins.net/images/checkmark.gif?a=commitdiff_plain;h=9abe0a87af0eedf581b9fae58fd1c62974ca004b;p=zfs-ubuntu%2F.git

Fix mountpoint after full fs transfer if needed

Change-Id: Idd9f9ac83e4191e00c883469e6d3a9242e0a6e38
---

diff --git a/zfs-replicate b/zfs-replicate
index cd38657..352c8e1 100755
--- a/zfs-replicate
+++ b/zfs-replicate
@@ -262,6 +262,12 @@ else
     if [ $? != 0 ]; then
       fatal_and_exit "-E- remote full $zfs send $current_backup_marker command failed on $hostname" $mailto
     fi
+    # Make sure the mount point of our backed up filesystem is mounted under the backups pool not the src filesystem
+    mountpoint=`$zfs get -H mountpoint ${backup_pool}/${remote_fs} | awk '{print $3}'`
+    backup_pool_mountpoint=`$zfs get -H mountpoint ${backup_pool} | awk '{print $3}'`
+    if [[ "$mountpoint" != "${backup_pool_mountpoint}/${remote_fs}" ]]; then
+       $zfs set mountpoint="${backup_pool_mountpoint}/${remote_fs}" "${backup_pool}/${remote_fs}"
+    fi
   fi
 fi