X-Git-Url: http://git.pippins.net/embedvideo/.git/static/gitweb.js?a=blobdiff_plain;f=zfs-restore;h=fab2b6ebf45041bb601aac5a3055cde8d5f2a209;hb=5167d7141f4c4da3d9142714f00497722a629ff7;hp=71ed8bd85ec926adc13c135aa35e6d83d726ff8f;hpb=be0effa3f84fee2396403d3c9220ba24a50f7b35;p=zfs-ubuntu%2F.git diff --git a/zfs-restore b/zfs-restore index 71ed8bd..fab2b6e 100755 --- a/zfs-restore +++ b/zfs-restore @@ -34,6 +34,12 @@ fi date=`date` echo "$date ZFS restore started: $src_pool/$src_fs -> $dst_hostname:$dst_pool/$dst_fs" +# check for localhost +if [[ $dst_hostname = "localhost" ]]; then + dst_hostname="" + ssh="" +fi + # Make sure the src pool and src filesystem exist, or print some errors zpool list -H "$src_pool" >/dev/null 2>&1 if [ $? != 0 ]; then @@ -48,7 +54,7 @@ fi src_pool_guid=`zpool get guid $src_pool 2>&1 | grep $src_pool | awk '{ print $3 }'` zpool get guid $src_pool > /dev/null 2>&1 if [ $? != 0 ]; then - fatal_and_exit "-E- Unable to extract the guid for the src pool: $src_pool" $mailto + fatal_and_exit "-E- Unable to extract the guid for the src pool on $hostname: $src_pool" $mailto fi # Setup our backup marker names @@ -61,29 +67,33 @@ if [ $? != 0 ]; then fi # Check to make sure the dst pool exists -ssh $dst_hostname "$zfs list ${dst_pool}" > /dev/null 2>&1 +$ssh $dst_hostname $zfs list ${dst_pool} > /dev/null 2>&1 if [ $? != 0 ]; then fatal_and_exit "-E- The destination pool '$dst_pool' does not exist. Create the pool '$dst_pool' and try again." fi # Check to make sure the dst filesystem does not exist -ssh $dst_hostname "$zfs list ${dst_pool}/${dst_fs}" > /dev/null 2>&1 +$ssh $dst_hostname $zfs list ${dst_pool}/${dst_fs} > /dev/null 2>&1 if [ $? == 0 ]; then fatal_and_exit "-E- The destination pool/filesystem '$dst_pool/$dst_fs' already exists. Destroy the filesystem '$dst_fs' and try again." fi # Now send the src filesystem if [[ -n "$SCRIPT_UNDER_TEST" ]]; then - echo "$zfs send -R $src_pool/$last_backup_marker | ssh $dst_hostname $zfs recv -dv $dst_pool" + echo "$zfs send -R $src_pool/$last_backup_marker | $ssh $dst_hostname $zfs recv -dv $dst_pool" else - $zfs send -R "$src_pool/$last_backup_marker" | ssh $dst_hostname "$zfs recv -dv $dst_pool" + if [[ $throttle_enable == 1 && -e $throttle ]]; then + $zfs send -R "$src_pool/$last_backup_marker" | $throttle $throttle_opt | $ssh $dst_hostname $zfs recv -dv $dst_pool + else + $zfs send -R "$src_pool/$last_backup_marker" | $ssh $dst_hostname $zfs recv -dv $dst_pool + fi fi # Now rename the dst filesystem (move it into place) if [[ -n "$SCRIPT_UNDER_TEST" ]]; then - echo "$dst_hostname $zfs rename $dst_pool/$src_fs $dst_pool/$dst_fs" + echo "$ssh $dst_hostname $zfs rename $dst_pool/$src_fs $dst_pool/$dst_fs" else - ssh $dst_hostname "$zfs rename $dst_pool/$src_fs $dst_pool/$dst_fs" + $ssh $dst_hostname $zfs rename $dst_pool/$src_fs $dst_pool/$dst_fs fi # All done!