-
Notifications
You must be signed in to change notification settings - Fork 9
/
test_bb.sh
76 lines (62 loc) · 1.5 KB
/
test_bb.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
71
72
73
74
75
#!/bin/bash
# Unit testing for Butterfly Backup system
echo "Python3 is installed?"
if [ -n "/bin/python3" ]; then
echo "Python3 exists!"
else
exit 1
fi
# Add execute permission on bb.py
echo "Add execute permission on bb.py"
chmod +x bb.py
# Create enviroment for first backup
repo=/tmp/bb_repo
if [ -d $repo ]; then
rm -rf /tmp/bb_*
fi
echo "Create enviroment for first backup"
mkdir $repo
echo "Create Butterfly Backup folder $repo"
data=/tmp/bb_client
mkdir $data
echo "Create client folder $data"
touch $data/file.txt $data/file.docx $data/file.xlsx
# Start first full backup
echo "Start full backup"
echo "Select operating system [Unix, MacOS, Windows]: "
read os
if [ "$os" = "Unix" ]; then
os="Unix"
elif [ "$os" = "MacOS" ]; then
os="MacOS"
elif [ "$os" = "Windows" ]; then
os="Windows"
else
echo "ERROR: available only Unix, MacOS, Windows"
exit 2
fi
echo "Test backup"
python3 bb.py backup --computer localhost --destination $repo --custom-data $data --type $os --verbose --log
# Test if backup was created
backup=$repo/localhost
if [ -d $backup ]; then
echo "Backup was created $backup"
else
echo "Backup failed"
exit 3
fi
# Test export
echo "Test export"
exp_data="/tmp/bb_exp"
mkdir $exp_data
python3 bb.py export --catalog $repo --all --destination $exp_data --verbose --log
# Test if restore was performed
if [ -f "$exp_data/.catalog.cfg" ]; then
echo "Export was performed"
else
echo "Export failed"
exit 3
fi
# Check catalog
echo "Check catalog: $ cat $repo/.catalog.cfg"
cat $repo/.catalog.cfg