]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_002_pos.ksh
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/tests
/functional
/cli_root
/cli_common.kshlib
36 # Verifying 'zfs receive <volume>' works.
39 # 1. Fill in volume with some data
40 # 2. Create full and incremental send stream
41 # 3. Restore the send stream
42 # 4. Verify the restoring results.
45 verify_runnable
"global"
52 while (( i
< ${#orig_snap[*]} )); do
53 snapexists
${rst_snap[$i]} && \
54 log_must zfs destroy
-f ${rst_snap[$i]}
55 snapexists
${orig_snap[$i]} && \
56 log_must zfs destroy
-f ${orig_snap[$i]}
57 [[ -e ${bkup[$i]} ]] && \
58 log_must
rm -rf ${bkup[$i]}
63 for ds
in $rst_vol $rst_root; do
64 datasetexists
$ds && \
65 log_must zfs destroy
-Rf $ds
69 log_assert
"Verifying 'zfs receive <volume>' works."
72 set -A orig_snap
"$TESTPOOL/$TESTVOL@init_snap" "$TESTPOOL/$TESTVOL@inc_snap"
73 set -A bkup
"/var/tmp/fullbkup" "/var/tmp/incbkup"
74 rst_root
=$TESTPOOL/rst_ctr
75 rst_vol
=$rst_root/$TESTVOL
76 set -A rst_snap
"${rst_vol}@init_snap" "${rst_vol}@inc_snap"
79 # Preparations for testing
81 log_must zfs create
$rst_root
82 [[ ! -d $TESTDIR1 ]] && \
83 log_must mkdir
-p $TESTDIR1
84 log_must zfs
set mountpoint
=$TESTDIR1 $rst_root
87 while (( i
< ${#orig_snap[*]} )); do
88 log_must zfs snapshot
${orig_snap[$i]}
90 log_must
eval "zfs send ${orig_snap[$i]} > ${bkup[$i]}"
92 log_must
eval "zfs send -i ${orig_snap[(( i - 1 ))]} \
93 ${orig_snap[$i]} > ${bkup[$i]}"
100 while (( i
< ${#bkup[*]} )); do
101 log_must
eval "zfs receive $rst_vol < ${bkup[$i]}"
102 ! datasetexists
$rst_vol ||
! snapexists
${rst_snap[$i]} && \
103 log_fail
"Restoring volume fails."
108 log_pass
"Verifying 'zfs receive <volume>' succeeds."