From 9abe0a87af0eedf581b9fae58fd1c62974ca004b Mon Sep 17 00:00:00 2001
From: "Alan J. Pippin" <ajp@pippins.net>
Date: Fri, 1 Dec 2023 10:24:34 -0700
Subject: [PATCH] Fix mountpoint after full fs transfer if needed

Change-Id: Idd9f9ac83e4191e00c883469e6d3a9242e0a6e38
---
 zfs-replicate | 6 ++++++
 1 file changed, 6 insertions(+)

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
  
-- 
2.34.1