fi
}
-# Mount the local backup pool if needed and the option is given to do so, else error out
+# Import the local backup pool if needed and the option is given to do so, else error out
zpool list -H "$backup_pool" >/dev/null 2>&1
if [ $? != 0 ]; then
if [[ $import_export_backup_pool == 1 ]]; then
read
for snap in `zfs list -t snapshot 2>/dev/null | grep "^$zfs_pool" | grep "$snap_pattern" | awk '{print $1}'`; do
+ echo " destroying snapshot: $snap"
zfs destroy "$snap" 2>/dev/null
done
-echo "-> Snapshots removed"
\ No newline at end of file
+echo "-> Snapshots removed"
for i in $pools
do
+ # Import the local pool if needed and option was given to do so, else error out
+ zpool list -H "$i" >/dev/null 2>&1
+ if [ $? != 0 ]; then
+ if [[ $import_export_backup_pool == 1 ]]; then
+ zpool import $i
+ if [ $? != 0 ]; then
+ echo "-E- unable to import the pool $i"
+ exit 1
+ fi
+ else
+ echo "-E- The local pool, '$i' doesn't seem to exist."
+ exit 1
+ fi
+ fi
+
# Check to see if any zfs filesystem has a scrub being performed on it now.
# If it does, we cannot perform more than one scrub operation at a time.
while true; do
zpool status $i | $mailx -s "zpool scrub $i found errors" $mailto
fi
-done
+ # Export the local pool if told to do so
+ if [[ $import_export_backup_pool == 1 ]]; then
+ zpool export $i
+ if [ $? != 0 ]; then
+ fatal_and_exit "-E- unable to export the local pool $i"
+ fi
+ fi
+ # Update NFS mounts
+ filesystems=`zfs list -t filesystem | grep "^$i" | grep -v "$i/$i" | grep -v "^$i " | awk '{ print $1 }' | tr '\n' ' '`
+ zfs set sharenfs=on $filesystems
+
+done