diff --git a/README.md b/README.md index a4cd7efd3..e601af9bf 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ * [Install Percona server on CentOS](#install-percona-server-on-centos) * [Install MariaDB on Ubuntu](#install-mariadb-on-ubuntu) * [Install Plugins](#install-plugins) + * [Use Percona XtraBackup](#use-percona-xtrabackup) 4. [Reference - An under-the-hood peek at what the module is doing and how](REFERENCE.md) 5. [Limitations - OS compatibility, etc.](#limitations) 6. [Development - Guide for contributing to the module](#development) @@ -392,6 +393,69 @@ mysql::server::db: ### Install Plugins Plugins can be installed by using the `mysql_plugin` defined type. See `examples/mysql_plugin.pp` for futher examples. + +### Use Percona XtraBackup + +This example shows how to configure MySQL backups with Percona XtraBackup. This sets up a weekly cronjob to perform a full backup and additional daily cronjobs for incremental backups. Each backup will create a new directory. A cleanup job will automatically remove backups that are older than 15 days. + +```puppet +yumrepo { 'percona': + descr => 'CentOS $releasever - Percona', + baseurl => 'http://repo.percona.com/release/$releasever/RPMS/$basearch', + gpgkey => 'https://www.percona.com/downloads/RPM-GPG-KEY-percona https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', + enabled => 1, + gpgcheck => 1, +} + +class { 'mysql::server::backup': + backupuser => 'myuser', + backuppassword => 'mypassword', + backupdir => '/tmp/backups', + provider => 'xtrabackup', + rotate => 15, + execpath => '/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin', + time => ['23', '15'], +} +``` + +If the daily or weekly backup was successful, then the empty file `/tmp/mysqlbackup_success` is created, which makes it easy to monitor the status of the database backup. + +After two weeks the backup directory should look similar to the example below. + +``` +/tmp/backups/2019-11-10_full +/tmp/backups/2019-11-11_23-15-01 +/tmp/backups/2019-11-13_23-15-01 +/tmp/backups/2019-11-13_23-15-02 +/tmp/backups/2019-11-14_23-15-01 +/tmp/backups/2019-11-15_23-15-02 +/tmp/backups/2019-11-16_23-15-01 +/tmp/backups/2019-11-17_full +/tmp/backups/2019-11-18_23-15-01 +/tmp/backups/2019-11-19_23-15-01 +/tmp/backups/2019-11-20_23-15-02 +/tmp/backups/2019-11-21_23-15-01 +/tmp/backups/2019-11-22_23-15-02 +/tmp/backups/2019-11-23_23-15-01 +``` + +A drawback of using incremental backups is the need to keep at least 7 days of backups, otherwise the full backups is removed early and consecutive incremental backups will fail. Furthermore an incremental backups becomes obsolete once the required full backup was removed. + +The next example uses XtraBackup with incremental backups disabled. In this case the daily cronjob will always perform a full backup. + +```puppet +class { 'mysql::server::backup': + backupuser => 'myuser', + backuppassword => 'mypassword', + backupdir => '/tmp/backups', + provider => 'xtrabackup', + incremental_backups => false, + rotate => 5, + execpath => '/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin', + time => ['23', '15'], +} +``` + ## Reference ### Classes diff --git a/manifests/backup/mysqlbackup.pp b/manifests/backup/mysqlbackup.pp index ab0bd17a5..6e805bc25 100644 --- a/manifests/backup/mysqlbackup.pp +++ b/manifests/backup/mysqlbackup.pp @@ -27,6 +27,7 @@ $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', $optional_args = [], + $incremental_backups = false, ) inherits mysql::params { mysql_user { "${backupuser}@localhost": diff --git a/manifests/backup/mysqldump.pp b/manifests/backup/mysqldump.pp index 51155081a..0fb07b298 100644 --- a/manifests/backup/mysqldump.pp +++ b/manifests/backup/mysqldump.pp @@ -28,6 +28,7 @@ $optional_args = [], $mysqlbackupdir_ensure = 'directory', $mysqlbackupdir_target = undef, + $incremental_backups = false, ) inherits mysql::params { unless $::osfamily == 'FreeBSD' { diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index 1f8234ec8..305e891d2 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -51,9 +51,18 @@ } if $incremental_backups { + # Warn if old backups are removed too soon. Incremental backups will fail + # if the full backup is no longer available. + if ($backuprotate.convert_to(Integer) < 7) { + warning(translate('The value for `backuprotate` is too low, it must be set to at least 7 days when using incremental backups.')) + } + + # The --target-dir uses a more predictable value for the full backup so + # that it can easily be calculated and used in incremental backup jobs. + # Besides that it allows to have multiple full backups. cron { 'xtrabackup-weekly': ensure => $ensure, - command => "/usr/local/sbin/xtrabackup.sh --target-dir=${backupdir} ${additional_cron_args}", + command => "/usr/local/sbin/xtrabackup.sh --target-dir=${backupdir}/$(date +\\%F)_full ${additional_cron_args}", user => 'root', hour => $time[0], minute => $time[1], @@ -62,13 +71,23 @@ } } + # Wether to use GNU or BSD date format. + case $::osfamily { + 'FreeBSD','OpenBSD': { + $dateformat = '$(date -v-sun +\\%F)_full' + } + default: { + $dateformat = '$(date -d "last sunday" +\\%F)_full' + } + } + $daily_cron_data = ($incremental_backups) ? { true => { - 'directories' => "--incremental-basedir=${backupdir} --target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)", + 'directories' => "--incremental-basedir=${backupdir}/${dateformat} --target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)", 'weekday' => '1-6', }, false => { - 'directories' => "--target-dir=${backupdir}", + 'directories' => "--target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)", 'weekday' => '*', }, } diff --git a/manifests/params.pp b/manifests/params.pp index dd15fa5f0..2058e1190 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -38,7 +38,7 @@ $client_dev_package_provider = undef $daemon_dev_package_ensure = 'present' $daemon_dev_package_provider = undef - $xtrabackup_package_name = 'percona-xtrabackup' + $xtrabackup_package_name_default = 'percona-xtrabackup' case $::osfamily { @@ -55,8 +55,12 @@ /^(RedHat|CentOS|Scientific|OracleLinux)$/: { if versioncmp($::operatingsystemmajrelease, '7') >= 0 { $provider = 'mariadb' + if versioncmp($::operatingsystemmajrelease, '8') >= 0 { + $xtrabackup_package_name_override = 'percona-xtrabackup-24' + } } else { $provider = 'mysql' + $xtrabackup_package_name_override = 'percona-xtrabackup-20' } if versioncmp($::operatingsystemmajrelease, '8') >= 0 { $java_package_name = 'mariadb-java-client' @@ -153,6 +157,7 @@ $root_group = 'root' $mysql_group = 'mysql' $server_service_name = 'mysql' + $xtrabackup_package_name_override = 'xtrabackup' if $::operatingsystem =~ /(SLES|SLED)/ { if versioncmp( $::operatingsystemmajrelease, '12' ) >= 0 { @@ -227,6 +232,10 @@ } else { $php_package_name = 'php5-mysql' } + if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') < 0) or + ($::operatingsystem == 'Debian') { + $xtrabackup_package_name_override = 'percona-xtrabackup-24' + } $python_package_name = 'python-mysqldb' $ruby_package_name = $::lsbdistcodename ? { @@ -519,6 +528,12 @@ }, } + if defined('$xtrabackup_package_name_override') { + $xtrabackup_package_name = pick($xtrabackup_package_name_override, $xtrabackup_package_name_default) + } else { + $xtrabackup_package_name = $xtrabackup_package_name_default + } + ## Additional graceful failures if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '4' and $::operatingsystem != 'Amazon' { fail(translate('Unsupported platform: puppetlabs-%{module_name} only supports RedHat 5.0 and beyond.', {'module_name' => $module_name})) diff --git a/manifests/server/backup.pp b/manifests/server/backup.pp index 07345f00e..5cc780fe9 100644 --- a/manifests/server/backup.pp +++ b/manifests/server/backup.pp @@ -48,6 +48,8 @@ # Dump stored routines (procedures and functions) from dumped databases when doing a `file_per_database` backup. # @param include_triggers # Dump triggers for each dumped table when doing a `file_per_database` backup. +# @param incremental_backups +# A flag to activate/deactivate incremental backups. Currently only supported by the xtrabackup provider. # @param ensure # @param time # An array of two elements to set the backup time. Allows ['23', '5'] (i.e., 23:05) or ['3', '45'] (i.e., 03:45) for HH:MM times. @@ -88,6 +90,7 @@ $provider = 'mysqldump', $maxallowedpacket = '1M', $optional_args = [], + $incremental_backups = true, ) inherits mysql::params { if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ { @@ -120,6 +123,7 @@ 'execpath' => $execpath, 'maxallowedpacket' => $maxallowedpacket, 'optional_args' => $optional_args, + 'incremental_backups' => $incremental_backups, } }) } diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb index 057a34072..34080bdb2 100644 --- a/spec/acceptance/mysql_backup_spec.rb +++ b/spec/acceptance/mysql_backup_spec.rb @@ -134,3 +134,220 @@ class { 'mysql::server::backup': # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength end end + +context 'with xtrabackup enabled' do + context 'should work with no errors', if: ((os[:family] == 'debian' && os[:release].to_i >= 8) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 6)) do # rubocop:disable Metrics/LineLength + pp = <<-MANIFEST + class { 'mysql::server': root_password => 'password' } + mysql::db { [ + 'backup1', + 'backup2' + ]: + user => 'backup', + password => 'secret', + } + case $facts['os']['family'] { + /Debian/: { + file { '/tmp/percona-release_latest.deb': + ensure => present, + source => "http://repo.percona.com/apt/percona-release_latest.${facts['os']['distro']['codename']}_all.deb", + } + ensure_packages('gnupg') + ensure_packages('gnupg2') + ensure_packages('percona-release',{ + ensure => present, + provider => 'dpkg', + source => '/tmp/percona-release_latest.deb', + notify => Exec['apt-get update'], + }) + exec { 'apt-get update': + path => '/usr/bin:/usr/sbin:/bin:/sbin', + refreshonly => true, + } + } + /RedHat/: { + # RHEL/CentOS 5 is no longer supported by Percona, but older versions + # of the repository are still available. + if versioncmp($::operatingsystemmajrelease, '6') >= 0 { + $percona_url = 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm' + $epel_url = "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm" + } else { + $percona_url = 'http://repo.percona.com/yum/release/5/os/noarch/percona-release-0.1-3.noarch.rpm' + $epel_url = 'https://archives.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm' + } + ensure_packages('percona-release',{ + ensure => present, + provider => 'rpm', + source => $percona_url, + }) + ensure_packages('epel-release',{ + ensure => present, + provider => 'rpm', + source => $epel_url, + }) + if ($facts['os']['name'] == 'Scientific') { + # $releasever resolves to '6.10' instead of '6' which breaks Percona repos + file { '/etc/yum/vars/releasever': + ensure => present, + content => '6', + } + } + } + default: { } + } + class { 'mysql::server::backup': + backupuser => 'myuser', + backuppassword => 'mypassword', + backupdir => '/tmp/xtrabackups', + provider => 'xtrabackup', + execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', + } + MANIFEST + it 'when configuring mysql backup' do + idempotent_apply(pp) + end + end + + describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 8) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 6)) do # rubocop:disable Metrics/LineLength + before(:all) do + pre_run + end + + it 'runs xtrabackup.sh full backup with no errors' do + run_shell('/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/xtrabackups/$(date +%F)_full --backup 2>&1 | tee /tmp/xtrabackup_full.log') do |r| + expect(r.exit_code).to be_zero + end + end + + it 'xtrabackup reports success for the full backup' do + # NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead. + run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup_full.log') do |r| + expect(r.exit_code).to be_zero + end + end + + it 'creates a subdirectory for the full backup' do + run_shell('find /tmp/xtrabackups -mindepth 1 -maxdepth 1 -type d -name $(date +%Y)\*full | wc -l') do |r| + expect(r.stdout).to match(%r{1}) + expect(r.exit_code).to be_zero + end + end + + it 'runs xtrabackup.sh incremental backup with no errors' do + run_shell('sleep 1') + run_shell('/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/xtrabackups/$(date +%F)_full --target-dir=/tmp/xtrabackups/$(date +%F_%H-%M-%S) --backup 2>&1 | tee /tmp/xtrabackup_inc.log') do |r| # rubocop:disable Metrics/LineLength + expect(r.exit_code).to be_zero + end + end + + it 'xtrabackup reports success for the incremental backup' do + # NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead. + run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup_inc.log') do |r| + expect(r.exit_code).to be_zero + end + end + + it 'creates a new subdirectory for each backup' do + run_shell('find /tmp/xtrabackups -mindepth 1 -maxdepth 1 -type d -name $(date +%Y)\* | wc -l') do |r| + expect(r.stdout).to match(%r{2}) + expect(r.exit_code).to be_zero + end + end + end + # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength +end + +context 'with xtrabackup enabled and incremental backups disabled' do + context 'should work with no errors', if: ((os[:family] == 'debian' && os[:release].to_i >= 8) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 6)) do # rubocop:disable Metrics/LineLength + pp = <<-MANIFEST + class { 'mysql::server': root_password => 'password' } + mysql::db { [ + 'backup1', + 'backup2' + ]: + user => 'backup', + password => 'secret', + } + case $facts['os']['family'] { + /Debian/: { + file { '/tmp/percona-release_latest.deb': + ensure => present, + source => "http://repo.percona.com/apt/percona-release_latest.${facts['os']['distro']['codename']}_all.deb", + } + ensure_packages('gnupg') + ensure_packages('gnupg2') + ensure_packages('percona-release',{ + ensure => present, + provider => 'dpkg', + source => '/tmp/percona-release_latest.deb', + notify => Exec['apt-get update'], + }) + exec { 'apt-get update': + path => '/usr/bin:/usr/sbin:/bin:/sbin', + refreshonly => true, + } + } + /RedHat/: { + # RHEL/CentOS 5 is no longer supported by Percona, but older versions + # of the repository are still available. + if versioncmp($::operatingsystemmajrelease, '6') >= 0 { + $percona_url = 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm' + $epel_url = "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm" + } else { + $percona_url = 'http://repo.percona.com/yum/release/5/os/noarch/percona-release-0.1-3.noarch.rpm' + $epel_url = 'https://archives.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm' + } + ensure_packages('percona-release',{ + ensure => present, + provider => 'rpm', + source => $percona_url, + }) + ensure_packages('epel-release',{ + ensure => present, + provider => 'rpm', + source => $epel_url, + }) + if ($facts['os']['name'] == 'Scientific') { + # $releasever resolves to '6.10' instead of '6' which breaks Percona repos + file { '/etc/yum/vars/releasever': + ensure => present, + content => '6', + } + } + } + default: { } + } + class { 'mysql::server::backup': + backupuser => 'myuser', + backuppassword => 'mypassword', + backupdir => '/tmp/xtrabackups', + provider => 'xtrabackup', + incremental_backups => false, + execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', + } + MANIFEST + it 'when configuring mysql backup' do + idempotent_apply(pp) + end + end + + describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 8) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 6)) do # rubocop:disable Metrics/LineLength + before(:all) do + pre_run + end + + it 'runs xtrabackup.sh with no errors' do + run_shell('/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/xtrabackups/$(date +%F_%H-%M-%S) --backup 2>&1 | tee /tmp/xtrabackup.log') do |r| + expect(r.exit_code).to be_zero + end + end + + it 'xtrabackup reports success for the backup' do + # NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead. + run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup.log') do |r| + expect(r.exit_code).to be_zero + end + end + end + # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength +end diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb index c1e779a2a..a4daa2fba 100644 --- a/spec/classes/mysql_backup_xtrabackup_spec.rb +++ b/spec/classes/mysql_backup_xtrabackup_spec.rb @@ -27,30 +27,58 @@ class { 'mysql::server': } ) end + package = if facts[:osfamily] == 'RedHat' + if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '8') >= 0 + 'percona-xtrabackup-24' + elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0 + 'percona-xtrabackup' + else + 'percona-xtrabackup-20' + end + elsif facts[:operatingsystem] == 'Debian' + 'percona-xtrabackup-24' + elsif facts[:operatingsystem] == 'Ubuntu' + if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '16') >= 0 + 'percona-xtrabackup' + else + 'percona-xtrabackup-24' + end + elsif facts[:osfamily] == 'Suse' + 'xtrabackup' + else + 'percona-xtrabackup' + end + it 'contains the weekly cronjob' do is_expected.to contain_cron('xtrabackup-weekly') .with( ensure: 'present', - command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp --backup', + command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup', user: 'root', hour: '23', minute: '5', weekday: '0', ) - .that_requires('Package[percona-xtrabackup]') + .that_requires("Package[#{package}]") end it 'contains the daily cronjob for weekdays 1-6' do + dateformat = case facts[:osfamily] + when 'FreeBSD', 'OpenBSD' + '$(date -v-sun +\%F)_full' + else + '$(date -d "last sunday" +\%F)_full' + end is_expected.to contain_cron('xtrabackup-daily') .with( ensure: 'present', - command: '/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup', + command: "/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/#{dateformat} --target-dir=/tmp/$(date +\\\%F_\\\%H-\\\%M-\\\%S) --backup", user: 'root', hour: '23', minute: '5', weekday: '1-6', ) - .that_requires('Package[percona-xtrabackup]') + .that_requires("Package[#{package}]") end end @@ -84,30 +112,59 @@ class { 'mysql::server': } { additional_cron_args: '--backup --skip-ssl' }.merge(default_params) end + package = if facts[:osfamily] == 'RedHat' + if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '8') >= 0 + 'percona-xtrabackup-24' + elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0 + 'percona-xtrabackup' + else + 'percona-xtrabackup-20' + end + elsif facts[:operatingsystem] == 'Debian' + 'percona-xtrabackup-24' + elsif facts[:operatingsystem] == 'Ubuntu' + if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '16') >= 0 + 'percona-xtrabackup' + else + 'percona-xtrabackup-24' + end + elsif facts[:osfamily] == 'Suse' + 'xtrabackup' + else + 'percona-xtrabackup' + end + + dateformat = case facts[:osfamily] + when 'FreeBSD', 'OpenBSD' + '$(date -v-sun +\%F)_full' + else + '$(date -d "last sunday" +\%F)_full' + end + it 'contains the weekly cronjob' do is_expected.to contain_cron('xtrabackup-weekly') .with( ensure: 'present', - command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp --backup --skip-ssl', + command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup --skip-ssl', user: 'root', hour: '23', minute: '5', weekday: '0', ) - .that_requires('Package[percona-xtrabackup]') + .that_requires("Package[#{package}]") end it 'contains the daily cronjob for weekdays 1-6' do is_expected.to contain_cron('xtrabackup-daily') .with( ensure: 'present', - command: '/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup --skip-ssl', + command: "/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/#{dateformat} --target-dir=/tmp/$(date +\\\%F_\\\%H-\\\%M-\\\%S) --backup --skip-ssl", user: 'root', hour: '23', minute: '5', weekday: '1-6', ) - .that_requires('Package[percona-xtrabackup]') + .that_requires("Package[#{package}]") end end @@ -123,7 +180,7 @@ class { 'mysql::server': } it 'contains the daily cronjob with all weekdays' do is_expected.to contain_cron('xtrabackup-daily').with( ensure: 'present', - command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp --backup', + command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup', user: 'root', hour: '23', minute: '5', diff --git a/templates/xtrabackup.sh.erb b/templates/xtrabackup.sh.erb index c12cd07ad..0f7a98ccc 100644 --- a/templates/xtrabackup.sh.erb +++ b/templates/xtrabackup.sh.erb @@ -26,9 +26,9 @@ set -o pipefail cleanup() { <%- if @kernel == 'SunOS' -%> - gfind "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | gxargs -0 -r rm -f + gfind "${DIR}/" -mindepth 1 -maxdepth 1 -mtime +${ROTATE} -print0 | gxargs -0 -r rm -rf <%- else -%> - find "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | xargs -0 -r rm -f + find "${DIR}/" -mindepth 1 -maxdepth 1 -mtime +${ROTATE} -print0 | xargs -0 -r rm -rf <%- end -%> }