File: rawfs_clone_restore_test

package info (click to toggle)
partclone 0.3.45-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,040 kB
  • sloc: ansic: 137,670; sh: 1,835; xml: 1,820; makefile: 573; asm: 383; perl: 106; sed: 16
file content (110 lines) | stat: -rwxr-xr-x 3,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash

. "$(dirname "$0")"/_common
break_debug=0
manual_fs=$1

test_fs=$mountable_fs
dd_count=$normal_size
[ -z $manual_fs ] || test_fs=$manual_fs

source_partition=""
target_partition="/dev/vdb2"
target_image="/test/partclone-test.img"
source_mountpoint="/test/source"
target_mountpoint="/test/target"
data_pool="/test/datapool/"
chfile="./md5.log"
cchfile="/test/checksum_test.log"

if [ "X$SOURCEPART" != "X" ]; then
    source_partition=$SOURCEPART
fi

if [ "X$TARGETPART" != "X" ]; then
    target_partition=$TARGETPART
fi

#main

# clean partition

dd if=/dev/zero of=$target_partition bs=1M count=4096

for fs in $test_fs; do
    echo -e "Advanced $fs test"
    echo -e "==========================\n"
    mkdir -p $source_mountpoint $target_mountpoint $data_pool
    umount $target_mountpoint $source_mountpoint
    set -e
    ptlfs=$(_ptlname $fs)
    logfile="/test/clone-$fs.log"

    echo -e "\n__device to device clone__, $source_partition to $target_partition\n"
    echo -e "    $ptlfs -d -b -s $source_partition -o $target_partition -L $logfile\n"
    _ptlbreak
    $ptlfs -q -d -b -s $source_partition -o $target_partition -L $logfile
    _check_return_code

    echo -e "\n__check data__\n"
    _ptlbreak
    if [ "$fs" = "apfs" ]; then
        fsapfsmount $target_partition $target_mountpoint
    elif [ "$fs" = "ufs" ]; then
        mount -t ufs -o ufstype=ufs2,ro $target_partition $target_mountpoint
    elif [ "$fs" = "vmfs" ]; then
        vmfs-fuse $target_partition $target_mountpoint
    else
        mount -t $fs $target_partition $target_mountpoint
    fi
    pushd $target_mountpoint
    echo -e "\n    md5sum --quiet -c $chfile 2>&1 > $cchfile\n"
    md5sum --quiet -c $chfile 2>&1 > $cchfile
    popd
    umount $target_mountpoint
    echo -e "\n__done__\n"
    _check_return_code

    echo -e "\n__device to image clone__, $source_partition to $target_image\n"
    echo -e "    $ptlfs -d -c -s $source_partition -O $target_image -L $logfile -a 2 -k 64\n"
    _ptlbreak
    $ptlfs -q -d -c -s $source_partition -O $target_image -L $logfile -a 2 -k 64
    _check_return_code

    echo -e "\n__restore image to device__, $target_image to $target_partition\n"
    echo -e "    $ptlfs -d -r -s $target_image -o $target_partition -L $logfile\n"
    _ptlbreak
    dd if=/dev/zero of=$target_partition bs=512 count=32
    $ptlfs -q -d -r -s $target_image -o $target_partition -L $logfile
    _check_return_code

    echo -e "\n__check data__\n"
    _ptlbreak
    if [ "$fs" = "apfs" ]; then
        fsapfsmount $target_partition $target_mountpoint
    elif [ "$fs" = "ufs" ]; then
        mount -t ufs -o ufstype=ufs2,ro $target_partition $target_mountpoint
    elif [ "$fs" = "vmfs" ]; then
        vmfs-fuse $target_partition $target_mountpoint
    else
        mount -t $fs $target_partition $target_mountpoint
    fi
    pushd $target_mountpoint
    echo -e "\n    md5sum --quiet -c $chfile 2>&1 > $cchfile\n"
    md5sum --quiet -c $chfile 2>&1 > $cchfile
    popd
    umount $target_mountpoint
    echo -e "\n__done__\n"
    _check_return_code

    echo -e "\nclear tmp files\n"
    _ptlbreak
    set +e
    umount $target_mountpoint $source_mountpoint
    rm -r $target_mountpoint $source_mountpoint $logfile $cchfile $target_image
    _check_return_code

    echo -e "\n$fs test ok\n"

done
echo -e "\nFinish!\n\n"