From e733df7388e1e3e9ba49a6a696b1c1bd452ba0b8 Mon Sep 17 00:00:00 2001 From: Christian Fasnacht Date: Tue, 14 Jun 2016 14:49:50 +0200 Subject: [PATCH] add new backup dump parameter maxallowedpacket --- README.md | 4 ++++ manifests/backup/mysqlbackup.pp | 1 + manifests/backup/mysqldump.pp | 1 + manifests/backup/xtrabackup.pp | 1 + manifests/server/backup.pp | 2 ++ spec/classes/mysql_server_backup_spec.rb | 2 ++ templates/mysqlbackup.sh.erb | 3 ++- 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0dc448..e92f542 100644 --- a/README.md +++ b/README.md @@ -507,6 +507,10 @@ Sets the server backup implementation. Valid values are: * `mysqlbackup`: Implements backups with MySQL Enterprise Backup from Oracle. Backup type: Physical. To use this type of backup, you'll need the `meb` package, which is available in RPM and TAR formats from Oracle. For Ubuntu, you can use [meb-deb](https://github.com/dveeden/meb-deb) to create a package from an official tarball. * `xtrabackup`: Implements backups with XtraBackup from Percona. Backup type: Physical. +##### `maxallowedpacket` + +Define the maximum SQL statement size for the backup dump script. The default value is 1MB as this is the default Mysql Server value. + #### mysql::server::monitor ##### `mysql_monitor_username` diff --git a/manifests/backup/mysqlbackup.pp b/manifests/backup/mysqlbackup.pp index 9456a5f..ae70c1b 100644 --- a/manifests/backup/mysqlbackup.pp +++ b/manifests/backup/mysqlbackup.pp @@ -2,6 +2,7 @@ class mysql::backup::mysqlbackup ( $backupuser = '', $backuppassword = '', + $maxallowedpacket = '1M', $backupdir = '', $backupdirmode = '0700', $backupdirowner = 'root', diff --git a/manifests/backup/mysqldump.pp b/manifests/backup/mysqldump.pp index 6669124..3ff3c9b 100644 --- a/manifests/backup/mysqldump.pp +++ b/manifests/backup/mysqldump.pp @@ -3,6 +3,7 @@ class mysql::backup::mysqldump ( $backupuser = '', $backuppassword = '', $backupdir = '', + $maxallowedpacket = '1M', $backupdirmode = '0700', $backupdirowner = 'root', $backupdirgroup = $mysql::params::root_group, diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index 0f1c310..d43a4e4 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -3,6 +3,7 @@ class mysql::backup::xtrabackup ( $backupuser = '', $backuppassword = '', $backupdir = '', + $maxallowedpacket = '1M', $backupmethod = 'mysqldump', $backupdirmode = '0700', $backupdirowner = 'root', diff --git a/manifests/server/backup.pp b/manifests/server/backup.pp index 2c98284..d31a880 100644 --- a/manifests/server/backup.pp +++ b/manifests/server/backup.pp @@ -20,6 +20,7 @@ class mysql::server::backup ( $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', $provider = 'mysqldump', + $maxallowedpacket = '1M', ) { if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ { @@ -47,6 +48,7 @@ class mysql::server::backup ( 'prescript' => $prescript, 'postscript' => $postscript, 'execpath' => $execpath, + 'maxallowedpacket' => $maxallowedpacket, } }) diff --git a/spec/classes/mysql_server_backup_spec.rb b/spec/classes/mysql_server_backup_spec.rb index c1bc374..96cfdf4 100644 --- a/spec/classes/mysql_server_backup_spec.rb +++ b/spec/classes/mysql_server_backup_spec.rb @@ -12,10 +12,12 @@ describe 'mysql::server::backup' do let(:default_params) { { 'backupuser' => 'testuser', 'backuppassword' => 'testpass', + 'maxallowedpacket' => '1M', 'backupdir' => '/tmp', 'backuprotate' => '25', 'delete_before_dump' => true, 'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', + 'maxallowedpacket' => '1M', } } diff --git a/templates/mysqlbackup.sh.erb b/templates/mysqlbackup.sh.erb index 9cf1205..c2f080e 100755 --- a/templates/mysqlbackup.sh.erb +++ b/templates/mysqlbackup.sh.erb @@ -16,12 +16,13 @@ USER=<%= @backupuser %> PASS='<%= @backuppassword %>' +MAX_ALLOWED_PACKET=<%= @maxallowedpacket %> DIR=<%= @backupdir %> ROTATE=<%= [ Integer(@backuprotate) - 1, 0 ].max %> # Create temporary mysql cnf file. TMPFILE=`mktemp /tmp/backup.XXXXXX` || exit 1 -echo -e "[client]\npassword=$PASS\nuser=$USER" > $TMPFILE +echo -e "[client]\npassword=$PASS\nuser=$USER\nmax_allowed_packet=$MAX_ALLOWED_PACKET" > $TMPFILE # Ensure backup directory exist. mkdir -p $DIR