--- /dev/null
+#!/bin/bash
+
+# Author: Alan J. Pippin
+# Description: This script calls zfs-restore for each filesystem needing
+# to be restored (that was formerly replicated here) to another ZFS pool.
+
+# source our configuration
+config="${0%/*}/zfs-scripts.conf"
+[ -e "${config}.dist" ] && . ${config}.dist
+[ -e "${config}" ] && . ${config}
+
+# Setup some default values
+logfile="$logdir/zfs-replicate-all.log"
+
+# Setup our output
+if [[ -z "$SCRIPT_UNDER_TEST" ]]; then
+ exec >> $logfile 2>&1
+fi
+
+cleanup_and_exit() {
+ exit 1
+}
+trap cleanup_and_exit INT
+
+
+# See if the user has a specific pool to restore in mind
+restore_pool=$1
+
+# Restore every ZFS filesystem we were told to replicate
+echo `date` ZFS restore started
+
+# For each filesystem we are supposed to restore, do it
+for filesystem in $filesystems_to_replicate; do
+ dst_pool=${filesystem%%/*}
+ dst_fs=${filesystem#*/}
+ # Check to make sure the dst filesystem does not exist
+ ssh $remote "$zfs list ${dst_pool}/${dst_fs}" > /dev/null 2>&1
+ if [ $? != 0 ]; then
+ echo "$filesystem" | grep -q "$restore_pool"
+ if [ $? == 0 ]; then
+ # This filesystem matches our restore pool pattern
+ echo `date` Restoring $filesystem to $remote
+ zfs-restore $local_pool $filesystem $dst_pool $dst_fs $remote
+ fi
+ else
+ echo "-I- Filesystem already exists on destination. Skipping: $filesystem"
+ fi
+done
+
+# All done
+echo `date` ZFS restore complete
+