File tree 1 file changed +35
-1
lines changed
1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change 5
5
<%- end -%>
6
6
#
7
7
# A wrapper for Xtrabackup
8
- #
8
+
9
+ ROTATE=<%= [ Integer(@backuprotate) - 1, 0 ].max %>
10
+ DIR=<%= @backupdir %>
11
+
12
+ # Ensure backup directory exist.
13
+ mkdir -p $DIR
14
+
15
+ <%- if @kernel == 'Linux' -%>
16
+ set -o pipefail
17
+ <%- end -%>
18
+
9
19
<% if @prescript -%>
10
20
<%- [@prescript].flatten.compact.each do |script| %>
11
21
<%= script %>
12
22
<%- end -%>
13
23
<% end -%>
14
24
25
+
26
+ cleanup()
27
+ {
28
+ <%- if @kernel == 'SunOS' -%>
29
+ gfind "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | gxargs -0 -r rm -f
30
+ <%- else -%>
31
+ find "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | xargs -0 -r rm -f
32
+ <%- end -%>
33
+ }
34
+
35
+ <% if @delete_before_dump -%>
36
+ cleanup
37
+ <% end -%>
38
+
39
+
15
40
<%- _innobackupex_args = '' -%>
16
41
17
42
<%- if @backupuser and @backuppassword -%>
30
55
31
56
<%= @backupmethod -%> <%= _innobackupex_args %> $@
32
57
58
+
59
+ <% unless @delete_before_dump -%>
60
+ if [ $? -eq 0 ] ; then
61
+ cleanup
62
+ touch /tmp/mysqlbackup_success
63
+ fi
64
+ <% end -%>
65
+
66
+
33
67
<% if @postscript -%>
34
68
<%- [@postscript].flatten.compact.each do |script| %>
35
69
<%= script %>
You can’t perform that action at this time.
0 commit comments