3 # Author: Alan J. Pippin
4 # Description: This script calls zfs-restore for each filesystem needing
5 # to be restored (that was formerly replicated here) to another ZFS pool.
7 # source our configuration
8 config="${0%/*}/zfs-scripts.conf"
9 [ -e "${config}.dist" ] && . ${config}.dist
10 [ -e "${config}" ] && . ${config}
12 # Setup some default values
13 logfile="$logdir/zfs-replicate-all.log"
16 if [[ -z "$SCRIPT_UNDER_TEST" ]]; then
23 trap cleanup_and_exit INT
26 # See if the user has a specific pool to restore in mind
29 # Restore every ZFS filesystem we were told to replicate
30 echo `date` ZFS restore started
32 # For each filesystem we are supposed to restore, do it
33 for filesystem in $filesystems_to_replicate; do
34 dst_pool=${filesystem%%/*}
35 dst_fs=${filesystem#*/}
36 # Check to make sure the dst filesystem does not exist
37 ssh $remote "$zfs list ${dst_pool}/${dst_fs}" > /dev/null 2>&1
39 echo "$filesystem" | grep -q "$restore_pool"
41 # This filesystem matches our restore pool pattern
42 echo `date` Restoring $filesystem to $remote
43 zfs-restore $local_pool $filesystem $dst_pool $dst_fs $remote
46 echo "-I- Filesystem already exists on destination. Skipping: $filesystem"
51 echo `date` ZFS restore complete