-
Notifications
You must be signed in to change notification settings - Fork 47
/
S02restorebackups
executable file
·47 lines (35 loc) · 999 Bytes
/
S02restorebackups
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
#!/bin/bash
BACKUPS_DIR="/boot"
BACKUP_PATTERN="backup-*.tar.gz"
DATA_DIR="/data"
test -n "${OS_VERSION}" || source /etc/init.d/base
case "$1" in
start)
if ! ls ${BACKUPS_DIR}/${BACKUP_PATTERN} &>/dev/null; then
exit; # no backups
fi
mount -o remount,rw /boot
for file in ${BACKUPS_DIR}/${BACKUP_PATTERN}; do
msg_begin "Restoring backup from $(basename ${file})"
tar -mxf ${file} -C ${DATA_DIR}
if [[ $? == 0 ]]; then
rm ${file}
msg_done
else
msg_fail
fi
done
# source os_conf again, as it might have changed after restore
test -s /etc/init.d/os_conf && source /etc/init.d/os_conf
if [[ "${OS_DEBUG}" != "true" ]]; then
mount -o remount,ro /boot
fi
;;
stop)
true
;;
*)
echo "Usage: $0 {start}"
exit 1
esac
exit $?