-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsnebu-client-db-plugin-template
121 lines (103 loc) · 3.45 KB
/
snebu-client-db-plugin-template
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
### Snebu backup plugin template for databases
[ -z "${verbose}" ] && verbose=0
[ "${verbose}" -gt 0 ] && echo "Executing client plugin template" >&2
pluginpre=pluginpref
pluginpost=pluginpostf
# Initialize an internal housekeeping variable
# (Step 0)
dbstage=0
# Define the pre-backup script
pluginpref() {
[ "${verbose}" -gt 0 ] && echo "Executing client plugin pre script" >&2
# Stage 0 => haven't backed up the DB yet
if [ "${dbstage}" = 0 ]
then
# (Step 1)
# Save the current include/exclude list
OLD_INCLUDE=( "${INCLUDE[@]}" )
OLD_EXCLUDE=( "${EXCLUDE[@]}" )
OLD_EXCLUDEMATCH=( "${EXCLUDEMATCH[@]}" )
# Zero out exclude list
EXCLUDE=( )
EXCLUDEMATCH=( )
# Set the include list to include database files
DBF_FILES=( "$(
# Function to list database filenames to standard output
print_dbf_filenames
)" )
INCLUDE=( "${DBF_FILES[@]}" )
# Place DB in hot backup mode
begin_db_backup
# After this, snebu-client-backup takes over and backs up
# the above set include list. Then control jumps to
# pluginpost() with dbstage still set to 0
elif [ "${dbstage}" = 1 ]
then
# (Step 3)
DBF_LOG_FILES=( "$(
# Function to list archived transaction logs
print_dbf_log_filenames
)" )
INCLUDE=( "${DBF_LOG_FILES[@]}" )
# Back to the backup with the new include list, then
# off to pluginpost again with dbstage set to 1
fi
}
pluginpostf() {
[ "${verbose}" -gt 0 ] && echo "client plugin post" >&2
if [ "${dbstage}" = 0 ]
then
# (Step 2)
# Take DB out of hot backup mode
end_db_backup
# Define the next stage, and repeat the backup
dbstage=1
bkrepeat=1
# Now control jumps back to pluginpre() with dbstage=1
elif [ "${dbstage}" = 1 ]
then
# (Step 4)
# Restore the original include/exclude list, with the
# database files added to the exclude list.
INCLUDE=( "${OLD_INCLUDE[@]}" )
EXCLUDE=( "${OLD_EXCLUDE[@]}" "${DBF_FILES[@]}" "${DBF_LOG_FILES[@]}" )
EXCLUDEMATCH=( "${OLD_EXCLUDEMATCH[@]}" )
# Define the next stage, and repeat the backup
dbstage=2
bkrepeat=1
# Control jumps back to pluginpre(), however no more pre-
# processing is needed for stage 2, so the backup begins
# again with the original client include/exclude (plus the
# above database files added to the exclude).
elif [ "${dbstage}" = 2 ]
then
# (Step 5)
# Break the cycle, backup is completed for this host.
bkrepeat=0
fi
}
# Also, don't forget to fill in the functions referenced above:
begin_db_backup() {
[ "${verbose}" -gt 0 ] && echo "Begin DB backup" >&2
### Steps to place DB in hot backup mode
### Make sure to execute these on the target host being backed
### up if running from the backup server (in pull mode)
}
end_db_backup() {
[ "${verbose}" -gt 0 ] && echo "End DB backup" >&2
### Steps to DB out of hot backup mode
### Make sure to execute these on the target host being backed
### up if running from the backup server (in pull mode)
}
print_dbf_filenames() {
[ "${verbose}" -gt 0 ] && echo "Generating DBF filenames" >&2
### Output list of dbf file names
### Make sure to execute these on the target host being backed
### up if running from the backup server (in pull mode)
}
print_dbf_log_filenames() {
[ "${verbose}" -gt 0 ] && echo "Generating DBF log filenames" >&2
### Output list of archived transaction log file names
### Make sure to execute these on the target host being backed
### up if running from the backup server (in pull mode)
}