-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_backup.sh
executable file
·70 lines (54 loc) · 1.26 KB
/
test_backup.sh
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
#!/bin/zsh
set -e
if [[ $# -ne 1 ]]; then
echo "usage: test_backup.sh <dir to backup>"
exit 1
fi
: ${TMPDIR:=/tmp}
# unencrypted
SRC_DIR=$argv[1]
RESTORE_DIR=$TMPDIR/bk_restore
BK=(bk --verbose)
RDSO=rdso
export BK_DIR=$TMPDIR/bk
rm -rf $BK_DIR
mkdir $BK_DIR
$BK init
$BK backup test $SRC_DIR
sleep 1 # make sure times don't match
$BK backup test $SRC_DIR
sleep 1
$BK backup --base test test $SRC_DIR
$BK list
$BK fsck
$RDSO check $BK_DIR/indices/*idx
$RDSO check $BK_DIR/packs/*pack
for b in test `bk list | grep test@ | awk '{print $1}'`; do
rm -rf $RESTORE_DIR
echo Restoring backup $b
bk restore $b $RESTORE_DIR
(cd $SRC_DIR; for i in **/*(^/); do cmp $i $RESTORE_DIR/$i; done)
done
rm -rf $RESTORE_DIR
#encrypted
export BK_PASSPHRASE=foobar
rm -rf $BK_DIR
mkdir $BK_DIR
$BK init --encrypt
$BK backup test $SRC_DIR
sleep 1
$BK backup test $SRC_DIR
sleep 1
$BK backup --base test test $SRC_DIR
$BK list
$BK fsck
$RDSO check $BK_DIR/indices/*idx
$RDSO check $BK_DIR/packs/*pack
for b in test `bk list | grep test@ | awk '{print $1}'`; do
rm -rf $RESTORE_DIR
echo Restoring backup $b
bk restore $b $RESTORE_DIR
(cd $SRC_DIR; for i in **/*(^/); do cmp $i $RESTORE_DIR/$i; done)
done
rm -rf $RESTORE_DIR
rm -rf $BK_DIR