-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-backup
More file actions
executable file
·69 lines (52 loc) · 1.07 KB
/
run-backup
File metadata and controls
executable file
·69 lines (52 loc) · 1.07 KB
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
#!/bin/sh -e
SYNC=false
TYPE=
TYPE_SET=false
CONFIG_FILE=
CONFIG_FILE_SET=false
display_usage()
{
echo "Usage: $0 [-s | --sync] {-t | --type TYPE} {-c CONFIGFILE}"
}
while [ -n "$1" ]; do
case "$1" in
-c)
CONFIG_FILE="${2}"
CONFIG_FILE_SET=true
shift
;;
-h | --help)
display_usage
exit 0
;;
-s | --sync)
SYNC=true
;;
-t | --type)
TYPE="${2}"
TYPE_SET=true
shift
;;
*)
display_usage
exit 1
;;
esac
# We're done with the current argument, move to the next.
shift
done
if [ "${TYPE_SET}" = false ] || [ "${CONFIG_FILE_SET}" = false ]; then
display_usage
exit 1
fi
SYNC_RESULT=0
# sync if the user wants to
if [ "${SYNC}" = true ]; then
rsnapshot -c "${CONFIG_FILE}" sync
SYNC_RESULT="${?}"
fi
# exit if the sync didn't work
if [ "${SYNC_RESULT}" != 0 ]; then
exit 1
fi
rsnapshot -c "${CONFIG_FILE}" "${TYPE}"