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
|
#!/bin/bash
# Test vdi backup and restore
. ./common
for i in `seq 0 5`; do
_start_sheep $i
done
_wait_for_sheep 6
_cluster_format -c 6
_vdi_create test 12M
# create the first object
echo 0 | $DOG vdi write test 0 512
$DOG vdi snapshot test -s snap1
# create the second object
echo 1 | $DOG vdi write test $((4 * 1024 * 1024)) 512
$DOG vdi snapshot test -s snap2
# update the first object
echo 2 | $DOG vdi write test 0 512
$DOG vdi snapshot test -s snap3
# check vdis
_vdi_list
$DOG vdi tree | _filter_short_date
for i in `seq 1 3`; do
$DOG vdi read test -s snap$i | md5sum
done
# create backup files between snapshots
$DOG vdi backup test -F snap1 -s snap2 > $STORE/backup.1.2
$DOG vdi backup test -F snap1 -s snap3 > $STORE/backup.1.3
$DOG vdi backup test -F snap2 -s snap3 > $STORE/backup.2.3
# restore backups
$DOG vdi restore test -s snap1 < $STORE/backup.1.2
_vdi_list
$DOG vdi tree | _filter_short_date
$DOG vdi restore test -s 4 < $STORE/backup.2.3
_vdi_list
$DOG vdi tree | _filter_short_date
$DOG vdi restore test -s snap1 < $STORE/backup.1.3
_vdi_list
$DOG vdi tree | _filter_short_date
$DOG vdi restore test -s snap2 < $STORE/backup.2.3
_vdi_list
$DOG vdi tree | _filter_short_date
# check vdi contents
$DOG vdi read test | md5sum
for i in `seq 1 $($DOG vdi list | grep "^s " | wc -l)`; do
$DOG vdi read test -s $i | md5sum
done
# restore to non-existence snapshot, this must be error
$DOG vdi restore test -s non-existence-tag < $STORE/backup.2.3
true
|