-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdobackup.sh
65 lines (53 loc) · 1.32 KB
/
dobackup.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
#!/bin/bash
# 1. Mount Partition with do backup.sh and backup.sh in directory backup
# 2. Check partitions below
# 3. Run dobackup.sh
PARTITIONS=${PARTITIONS:-"sda1 sda2 sdb3 sdb5"}
BASEDIR=$(dirname $(readlink -f "$0"))
cd "$BASEDIR"
DESTINATION="${BASEDIR}/$(date +%Y%m%d)"
if [ -d "$DESTINATION" ] ; then
echo "Destination $DESTINATION already exists!"
exit 1
fi
if [ ! -x "${BASEDIR}/backup.sh" ] ; then
echo "Backup script not found!"
exit 1
fi
for i in $PARTITIONS ; do
if [ -d "$i" ] ; then
echo "Partition $i already exists!"
exit 1
fi
done
echo "Script: ${BASEDIR}/backup.sh"
echo "Partitions: $PARTITIONS"
echo "Destination: $DESTINATION"
echo
echo "Press Return to continue, CTRL+C to cancel..."
read dummy
for i in $PARTITIONS ; do
mkdir "$i"
mount -o ro "/dev/${i}" "$i"
RC=$?
if [ "$RC" != "0" ] ; then
echo "Error $RC mounting ${i}!"
exit 1
fi
done
mkdir "$DESTINATION"
echo "START: $(date)"
for i in $PARTITIONS ; do
echo "----------------------- start $i ------------------------"
"${BASEDIR}/backup.sh" "$i" "$DESTINATION"
RC=$?
echo "----------------------- end $i --------------------------"
if [ "$RC" != "0" ] ; then
exit 1;
fi
done
echo "END: $(date)"
for i in $PARTITIONS ; do
umount "$i"
rmdir $i
done