- zpool export $i
- if [ $? != 0 ]; then
- echo "-E- unable to export the local pool $i"
- zpool status $i | $mailx -s "zpool scrub on $hostname unable to export the local pool $i" "$mailto"
+ # Only export the pool if it is still imported
+ zpool list -H "$i" >/dev/null 2>&1
+ if [ $? == 0 ]; then
+ zpool export $i
+ if [ $? != 0 ]; then
+ echo "-E- unable to export the local pool $i"
+ zpool status $i | $mailx -s "zpool scrub on $hostname unable to export the local pool $i" "$mailto"
+ fi