X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=zfs-restore-all;fp=zfs-restore-all;h=76c7bf8a0e1cf850a940bc07bad73212f0b1d5d0;hb=b12a5ad3bc477a5369871300b89f5a658df11554;hp=0000000000000000000000000000000000000000;hpb=3829caa2e99fcf28afe3004c367ce19ab86d2274;p=zfs-nexenta%2F.git diff --git a/zfs-restore-all b/zfs-restore-all new file mode 100755 index 0000000..76c7bf8 --- /dev/null +++ b/zfs-restore-all @@ -0,0 +1,52 @@ +#!/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 +