]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/tests
/functional
/cli_root
/cli_common.kshlib
36 # Verifying 'zfs receive [<filesystem|snapshot>] -d <filesystem>' works.
39 # 1. Fill in fs with some data
40 # 2. Create full and incremental send stream
41 # 3. Receive the send stream
42 # 4. Verify the restoring results.
45 verify_runnable
"both"
51 datasetexists
$rst_root && \
52 log_must zfs destroy
-Rf $rst_root
54 snapexists
${orig_snap[$i]} && \
55 log_must zfs destroy
-f ${orig_snap[$i]}
56 log_must
rm -f ${bkup[$i]}
61 log_must
rm -rf $TESTDIR1
64 function recreate_root
66 datasetexists
$rst_root && \
67 log_must zfs destroy
-Rf $rst_root
68 if [[ -d $TESTDIR1 ]] ; then
69 log_must
rm -rf $TESTDIR1
71 log_must zfs create
$rst_root
72 log_must zfs
set mountpoint
=$TESTDIR1 $rst_root
75 log_assert
"Verifying 'zfs receive [<filesystem|snapshot>] -d <filesystem>' works."
78 typeset datasets
="$TESTPOOL/$TESTFS $TESTPOOL"
79 set -A bkup
"/var/tmp/fullbkup" "/var/tmp/incbkup"
82 rst_root
=$TESTPOOL/rst_ctr
83 rst_fs
=${rst_root}/$TESTFS
85 for orig_fs
in $datasets ; do
87 # Preparations for testing
91 set -A orig_snap
"${orig_fs}@init_snap" "${orig_fs}@inc_snap"
92 typeset mntpnt
=$
(get_prop mountpoint
${orig_fs})
93 set -A orig_data
"${mntpnt}/$TESTFILE1" "${mntpnt}/$TESTFILE2"
95 typeset relative_path
=""
96 if [[ ${orig_fs} == *"/"* ]]; then
97 relative_path
=${orig_fs#*/}
100 typeset leaf_fs
=${rst_root}/${relative_path}
102 rst_snap
=${leaf_fs}@snap
104 set -A rst_snap
"$rst_root/$TESTFS@init_snap" "$rst_root/$TESTFS@inc_snap"
105 set -A rst_snap2
"${leaf_fs}@init_snap" "${leaf_fs}@inc_snap"
106 set -A rst_data
"$TESTDIR1/$TESTFS/$TESTFILE1" "$TESTDIR1/$TESTFS/$TESTFILE2"
107 set -A rst_data2
"$TESTDIR1/${relative_path}/$TESTFILE1" "$TESTDIR1/${relative_path}/$TESTFILE2"
110 while (( i
< ${#orig_snap[*]} )); do
111 file_write
-o create
-f ${orig_data[$i]} -b 512 \
114 log_fail
"Writing data into zfs filesystem fails."
115 log_must zfs snapshot
${orig_snap[$i]}
117 log_must
eval "zfs send ${orig_snap[$i]} > ${bkup[$i]}"
119 log_must
eval "zfs send -i ${orig_snap[(( i - 1 ))]} \
120 ${orig_snap[$i]} > ${bkup[$i]}"
126 log_note
"Verifying 'zfs receive <filesystem>' works."
128 while (( i
< ${#bkup[*]} )); do
130 log_must zfs rollback
${rst_snap[0]}
132 log_must
eval "zfs receive $rst_fs < ${bkup[$i]}"
133 snapexists
${rst_snap[$i]} || \
134 log_fail
"Restoring filesystem fails. ${rst_snap[$i]} not exist"
135 compare_cksum
${orig_data[$i]} ${rst_data[$i]}
140 log_must zfs destroy
-Rf $rst_fs
142 log_note
"Verifying 'zfs receive <snapshot>' works."
144 while (( i
< ${#bkup[*]} )); do
146 log_must zfs rollback
${rst_snap[0]}
148 log_must
eval "zfs receive ${rst_snap[$i]} <${bkup[$i]}"
149 snapexists
${rst_snap[$i]} || \
150 log_fail
"Restoring filesystem fails. ${rst_snap[$i]} not exist"
151 compare_cksum
${orig_data[$i]} ${rst_data[$i]}
156 log_must zfs destroy
-Rf $rst_fs
158 log_note
"Verfiying 'zfs receive -d <filesystem>' works."
161 while (( i
< ${#bkup[*]} )); do
163 log_must zfs rollback
${rst_snap2[0]}
165 log_must
eval "zfs receive -d -F $rst_root <${bkup[$i]}"
166 snapexists
${rst_snap2[$i]} || \
167 log_fail
"Restoring filesystem fails. ${rst_snap2[$i]} not exist"
168 compare_cksum
${orig_data[$i]} ${rst_data2[$i]}
176 log_pass
"Verifying 'zfs receive [<filesystem|snapshot>] -d <filesystem>' succeeds."