Skip to content

Commit

Permalink
Backup Compression Optional
Browse files Browse the repository at this point in the history
Added a parameter to mysql::backup to make bzip2 compression
optional. Compression is enabled by default, so current behavior
is not affected.

Rationale:
We are storing our MySQL backups on a system with deduplication.
Compression and dedup do not play well together, so it's advantagous
to be able to disable it.
  • Loading branch information
fandingo authored and hunner committed Sep 26, 2012
1 parent 6a7d843 commit af30a52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions manifests/backup.pp
Expand Up @@ -6,6 +6,7 @@
# [*backupuser*] - The name of the mysql backup user.
# [*backuppassword*] - The password of the mysql backup user.
# [*backupdir*] - The target directory of the mysqldump.
# [*backupcompress*] - Boolean to compress backup with bzip2.
#
# Actions:
# GRANT SELECT, RELOAD, LOCK TABLES ON *.* TO 'user'@'localhost'
Expand All @@ -19,12 +20,14 @@
# backupuser => 'myuser',
# backuppassword => 'mypassword',
# backupdir => '/tmp/backups',
# backupcompress => true,
# }
#
class mysql::backup (
$backupuser,
$backuppassword,
$backupdir,
$backupcompress = true,
$ensure = 'present'
) {

Expand Down
2 changes: 1 addition & 1 deletion templates/mysqlbackup.sh.erb
Expand Up @@ -19,5 +19,5 @@ PATH=/usr/bin:/usr/sbin:/bin:/sbin

find $DIR -mtime +30 -exec rm -f {} \;
mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \
--all-databases | bzcat -zc > ${DIR}/mysql_backup_`date +%Y%m%d-%H%M%S`.sql.bz2
--all-databases <% if backupcompress %> | bzcat -zc <% end %> > ${DIR}/mysql_backup_`date +%Y%m%d-%H%M%S`.sql<% if backupcompress %>.bz2<% end %>

0 comments on commit af30a52

Please sign in to comment.