-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-clean.sh
executable file
·74 lines (59 loc) · 1.2 KB
/
test-clean.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
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
umount test/img
rm -rf test
mkdir test
dd if=/dev/zero of=test/img count=0 bs=1M seek=10 2>/dev/null
yes | mkfs.ext4 -q test/img >/dev/null
mkdir test/fs
mount test/img test/fs
export BACKUP_ROOT="$PWD/test/fs"
export BACKUP_TIME_FORMAT="%F %T"
export BACKUP_CONFIG="/dev/null"
./init.sh
size=500k
counta=4
countx=1
countz=1
countb=4
county=2
countc=4
verify() {
df -h test/fs
sqlite3 test/fs/backup.db 'select * from history ORDER BY filename;'
./backup.sh
# tree --inodes $BACKUP_ROOT
df -h test/fs
sqlite3 test/fs/backup.db 'select * from history ORDER BY filename;'
echo "looks good?"
read
}
mkfiles() { #name count
for i in $(seq $2); do
dd if=/dev/zero of=test/fs/current/$1$i bs=$size count=1 2>/dev/null
done
}
rmfiles() { #name count
for i in $(seq $2); do
rm test/fs/current/$1$i
done
}
mkfiles a $counta
mkfiles x $countx
mkfiles z $countx
./backup.sh
sleep 1
rmfiles x $countx
rmfiles z $countx
mkfiles b $countb
mkfiles y $county
./backup.sh
sleep 1
rmfiles y $county
mkfiles c $countc
sqlite3 test/fs/backup.db "update history set created='2019-01-01 00:00:00' where filename like 'z%';"
verify
umount test/img