-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlvm-snapshot-backup-wrapper.sh
executable file
·105 lines (90 loc) · 3.82 KB
/
lvm-snapshot-backup-wrapper.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
## vim:ts=4:sw=4:tw=200:nu:ai:nowrap:
##
## lvm-snapshot-backup-wrapper: A wrapper script for creating system backups with lvm-snaptool.sh and rdiff-backup/rsnapshot
##
## Created by Wolfram Schlich <wschlich@gentoo.org>
## Licensed under the GNU GPLv3
## Web: http://www.bashinator.org/projects/lvm-snapshot-backup-wrapper/
## Code: https://github.com/wschlich/lvm-snapshot-backup-wrapper/
##
##
## NOTES
## =====
## - you have to run 'bash -O extglob -O extdebug -n thisscriptfile' to test this script!
##
##
## bashinator basic variables
##
export __ScriptFile=${0##*/} # evaluates to "lvm-snaptoo.sh"
export __ScriptName=${__ScriptFile%.sh} # evaluates to "lvm-snapshot-backup-wrapper"
export __ScriptPath=${0%/*}; __ScriptPath=${__ScriptPath%/} # evaluates to /path/to/lvm-snapshot-backup-wrapper/lvm-snapshot-backup-wrapper.sh
export __ScriptHost=$(hostname -f) # evaluates to the current hostname, e.g. host.example.com
##
## bashinator library and config
##
## system installation of bashinator (and application):
##
## /etc/lvm-snapshot-backup-wrapper/bashinator.cfg.sh
## /usr/share/bashinator/bashinator.lib.0.sh
##
## accepting overrides using user-defined environment variables:
export __BashinatorConfig="${__BashinatorConfig:-/etc/${__ScriptName}/bashinator.cfg.sh}"
export __BashinatorLibrary="${__BashinatorLibrary:-/usr/share/bashinator/bashinator.lib.0.sh}" # APIv0
##
## not accepting overrides (for security reasons):
#export __BashinatorConfig="/etc/${__ScriptName}/bashinator.cfg.sh"
#export __BashinatorLibrary="/usr/share/bashinator/bashinator.lib.0.sh" # bashinator API v0
## local installation of bashinator and application in dedicated script path:
##
## /path/to/lvm-snapshot-backup-wrapper/bashinator.cfg.sh
## /path/to/lvm-snapshot-backup-wrapper/bashinator.lib.0.sh
##
#export __BashinatorConfig="${__ScriptPath}/bashinator.cfg.sh"
#export __BashinatorLibrary="${__ScriptPath}/bashinator.lib.0.sh" # bashinator API v0
## include required source files
if ! source "${__BashinatorConfig}"; then
echo "!!! FATAL: failed to source bashinator config '${__BashinatorConfig}'" 1>&2
exit 2
fi
if ! source "${__BashinatorLibrary}"; then
echo "!!! FATAL: failed to source bashinator library '${__BashinatorLibrary}'" 1>&2
exit 2
fi
##
## boot bashinator:
## - if configured, it can check for a minimum required bash version
## - if configured, it can enforce a safe PATH
## - if configured, it can enforce a specific umask
## - it enables required bash settings (e.g. extglob, extdebug)
##
__boot
##
## application library and config
##
## system installation of application config and library
##
## /etc/lvm-snapshot-backup-wrapper/lvm-snapshot-backup-wrapper.cfg.sh
## /usr/share/lvm-snapshot-backup-wrapper/lvm-snapshot-backup-wrapper.lib.sh
##
## accepting overrides using user-defined environment variables:
export ApplicationConfig="${ApplicationConfig:-/etc/${__ScriptName}/${__ScriptName}.cfg.sh}"
export ApplicationLibrary="${ApplicationLibrary:-/usr/share/${__ScriptName}/${__ScriptName}.lib.sh}"
##
## not accepting overrides (for security reasons)
#export ApplicationConfig="/etc/${__ScriptName}/${__ScriptName}.cfg.sh"
#export ApplicationLibrary="/usr/share/${__ScriptName}/${__ScriptName}.lib.sh"
## local installation of application config and library in dedicated script path:
##
## /path/to/lvm-snapshot-backup-wrapper/lvm-snapshot-backup-wrapper.cfg.sh
## /path/to/lvm-snapshot-backup-wrapper/lvm-snapshot-backup-wrapper.lib.sh
##
#export ApplicationConfig="${__ScriptPath}/${__ScriptName}.cfg.sh"
#export ApplicationLibrary="${__ScriptPath}/${__ScriptName}.lib.sh"
## include required source files (using bashinator functions with builtin error handling)
__requireSource "${ApplicationConfig}"
__requireSource "${ApplicationLibrary}"
##
## dispatch the application with all original command line arguments
##
__dispatch "${@}"