Skip to content

Commit fa6ea56

Browse files
Robert RothenbergRobert Rothenberg
Robert Rothenberg
authored and
Robert Rothenberg
committed
Added prototype excludedatabases option to mysql::server::backup
As per #449
1 parent 1454a5b commit fa6ea56

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Compatibility mode may fail. It may eat your MySQL server. PLEASE test it before
4545
###Beginning with MySQL
4646

4747
If you just want a server installed with the default options you can run
48-
`include '::mysql::server'`.
48+
`include '::mysql::server'`.
4949

5050
If you need to customize options, such as the root
5151
password or `/etc/my.cnf` settings, then you must also pass in an override hash:
@@ -216,7 +216,7 @@ The provider to use to manage the service.
216216

217217
#####`users`
218218

219-
Optional hash of users to create, which are passed to [mysql_user](#mysql_user).
219+
Optional hash of users to create, which are passed to [mysql_user](#mysql_user).
220220

221221
```puppet
222222
$users = {
@@ -233,7 +233,7 @@ $users = {
233233

234234
#####`grants`
235235

236-
Optional hash of grants, which are passed to [mysql_grant](#mysql_grant).
236+
Optional hash of grants, which are passed to [mysql_grant](#mysql_grant).
237237

238238
```puppet
239239
$grants = {
@@ -305,6 +305,11 @@ Boolean to determine if you should cleanup before backing up or after.
305305

306306
Array of databases to specifically back up.
307307

308+
#####`excludedatabases`
309+
310+
Array of databases to exclude from backups. Thus only works when
311+
`file_per_database` is true.
312+
308313
#####`file_per_database`
309314

310315
Whether a separate file be used per database.

manifests/server/backup.pp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
$ignore_events = true,
1212
$delete_before_dump = false,
1313
$backupdatabases = [],
14+
$excludedatabases = [],
1415
$file_per_database = false,
1516
$ensure = 'present',
1617
$time = ['23', '5'],

templates/mysqlbackup.sh.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cleanup
4040
<% end -%>
4141
<% if @backupdatabases.empty? -%>
4242
<% if @file_per_database -%>
43-
mysql -s -r -N -e 'SHOW DATABASES' | while read dbname
43+
mysql -s -r -N -e 'SHOW DATABASES' <% if !@excludedatabases.empty? %> | grep -v '^\(<% @excludedatabases.join('|') %>)$' <% end %> | while read dbname
4444
do
4545
mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \
4646
${EVENTS} \
@@ -53,7 +53,7 @@ mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \
5353
<% end -%>
5454
<% else -%>
5555
<% @backupdatabases.each do |db| -%>
56-
mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \
56+
mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \
5757
${EVENTS} \
5858
<%= db %><% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}<%= db %>_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %>
5959
<% end -%>

0 commit comments

Comments
 (0)