diff --git a/manifests/backup.pp b/manifests/backup.pp index f7aeb37..e82d1b7 100644 --- a/manifests/backup.pp +++ b/manifests/backup.pp @@ -33,7 +33,7 @@ class mysql::backup ( $backupcompress = true, $backuprotate = 30, $delete_before_dump = false, - $backupdatabases = false, + $backupdatabases = [], $ensure = 'present' ) { diff --git a/templates/mysqlbackup.sh.erb b/templates/mysqlbackup.sh.erb index caadc06..6d93f24 100644 --- a/templates/mysqlbackup.sh.erb +++ b/templates/mysqlbackup.sh.erb @@ -31,14 +31,14 @@ cleanup() cleanup <% end -%> -<% if @backupdatabases -%> +<% if @backupdatabases.empty? -%> +mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ + --all-databases <% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> +<% else -%> <% @backupdatabases.each do |db| -%> mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ <%= db %><% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}<%= db %>_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> <% end -%> -<% else -%> -mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ - --all-databases <% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> <% end -%> <% unless @delete_before_dump -%>