From 4f0ea6316476b44a7954f805f9b19fee228d3c40 Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Tue, 15 Oct 2019 23:55:42 +0200
Subject: [PATCH 01/12] fix xtrabackup target directory and related regressions

---
 manifests/backup/xtrabackup.pp               | 2 +-
 spec/classes/mysql_backup_xtrabackup_spec.rb | 6 +++---
 templates/xtrabackup.sh.erb                  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp
index 1f8234ec8..c6f9ada14 100644
--- a/manifests/backup/xtrabackup.pp
+++ b/manifests/backup/xtrabackup.pp
@@ -68,7 +68,7 @@
       'weekday'     => '1-6',
     },
     false => {
-      'directories' => "--target-dir=${backupdir}",
+      'directories' => "--target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)",
       'weekday'     => '*',
     },
   }
diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb
index c1e779a2a..f70a34837 100644
--- a/spec/classes/mysql_backup_xtrabackup_spec.rb
+++ b/spec/classes/mysql_backup_xtrabackup_spec.rb
@@ -31,7 +31,7 @@ class { 'mysql::server': }
           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_\%H-\%M-\%S) --backup',
               user: 'root',
               hour: '23',
               minute: '5',
@@ -88,7 +88,7 @@ class { 'mysql::server': }
           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_\%H-\%M-\%S) --backup --skip-ssl',
               user: 'root',
               hour: '23',
               minute: '5',
@@ -123,7 +123,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 bc01ba9e4..c91668ce6 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 -%>
 }
 

From 99ecc8c66f8ebc2dd8465d1393d5d3b1cf2fbfdb Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Wed, 16 Oct 2019 00:27:50 +0200
Subject: [PATCH 02/12] fix handling of incremental backups with xtrabackup

---
 manifests/backup/xtrabackup.pp               | 23 ++++++++++++++++++--
 spec/classes/mysql_backup_xtrabackup_spec.rb | 21 ++++++++++++++----
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp
index c6f9ada14..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,9 +71,19 @@
     }
   }
 
+  # 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 => {
diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb
index f70a34837..be920fae1 100644
--- a/spec/classes/mysql_backup_xtrabackup_spec.rb
+++ b/spec/classes/mysql_backup_xtrabackup_spec.rb
@@ -31,7 +31,7 @@ class { 'mysql::server': }
           is_expected.to contain_cron('xtrabackup-weekly')
             .with(
               ensure: 'present',
-              command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup',
+              command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup',
               user: 'root',
               hour: '23',
               minute: '5',
@@ -41,10 +41,16 @@ class { 'mysql::server': }
         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',
@@ -84,11 +90,18 @@ class { 'mysql::server': }
           { additional_cron_args: '--backup --skip-ssl' }.merge(default_params)
         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/$(date +\%F_\%H-\%M-\%S) --backup --skip-ssl',
+              command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup --skip-ssl',
               user: 'root',
               hour: '23',
               minute: '5',
@@ -101,7 +114,7 @@ class { 'mysql::server': }
           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',

From 815d79db9d0409e71f2964950184d9e6381f576d Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sat, 23 Nov 2019 23:32:22 +0100
Subject: [PATCH 03/12] MODULES-10023 add parameter $incremental_backups to
 parent class

---
 manifests/backup/mysqlbackup.pp | 1 +
 manifests/backup/mysqldump.pp   | 1 +
 manifests/server/backup.pp      | 4 ++++
 3 files changed, 6 insertions(+)

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/server/backup.pp b/manifests/server/backup.pp
index bc4f925f5..a57017ac6 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,
     }
   })
 }

From 7730e2731aab6ffa040b5f1c06e9d992b07578cd Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sun, 24 Nov 2019 00:43:54 +0100
Subject: [PATCH 04/12] MODULES-10023 add acceptance tests for xtrabackup

---
 spec/acceptance/mysql_backup_spec.rb | 130 +++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)

diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 057a34072..d497999a9 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -134,3 +134,133 @@ class { 'mysql::server::backup':
     # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength
   end
 end
+
+context 'with xtrabackup enabled' do
+  context 'should work with no errors' do
+    pp = <<-MANIFEST
+          class { 'mysql::server': root_password => 'password' }
+          mysql::db { [
+            'backup1',
+            'backup2'
+          ]:
+            user     => 'backup',
+            password => 'secret',
+          }
+          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/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') do
+    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
+      run_shell('grep "completed OK" /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
+      run_shell('grep "completed OK" /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' do
+    pp = <<-MANIFEST
+          class { 'mysql::server': root_password => 'password' }
+          mysql::db { [
+            'backup1',
+            'backup2'
+          ]:
+            user     => 'backup',
+            password => 'secret',
+          }
+          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/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') do
+    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
+      run_shell('grep "completed OK" /tmp/xtrabackup.log') do |r|
+        expect(r.exit_code).to be_zero
+      end
+    end
+  end
+  # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength
+end

From be838eb8f4bc8be1d3f551ac3f6c336dce2ace03 Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sun, 24 Nov 2019 00:48:38 +0100
Subject: [PATCH 05/12] MODULES-10023 add xtrabackup documentation

---
 README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/README.md b/README.md
index 57e9004e7..e9a7dc89e 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)
@@ -389,6 +390,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

From 0765d15e162feabe2fbf658f33c612693a13c7be Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sun, 24 Nov 2019 01:59:17 +0100
Subject: [PATCH 06/12] MODULES-10023 fix acceptance tests

---
 spec/acceptance/mysql_backup_spec.rb | 86 ++++++++++++++++++++++------
 1 file changed, 68 insertions(+), 18 deletions(-)

diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index d497999a9..8a88c8d8f 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -146,19 +146,44 @@ class { 'mysql::server': root_password => 'password' }
             user     => 'backup',
             password => 'secret',
           }
-          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,
+          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('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/: {
+              ensure_packages('percona-release',{
+                ensure   => present,
+                provider => 'rpm',
+                source   => 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm',
+              })
+              ensure_packages('epel-release',{
+                ensure   => present,
+                provider => 'rpm',
+                source   => "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm",
+              })
+            }
+            default: { }
           }
           class { 'mysql::server::backup':
-            backupuser        => 'myuser',
-            backuppassword    => 'mypassword',
-            backupdir         => '/tmp/xtrabackups',
-            provider          => 'xtrabackup',
-            execpath          => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
+            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
@@ -224,12 +249,37 @@ class { 'mysql::server': root_password => 'password' }
             user     => 'backup',
             password => 'secret',
           }
-          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,
+          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('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/: {
+              ensure_packages('percona-release',{
+                ensure   => present,
+                provider => 'rpm',
+                source   => 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm',
+              })
+              ensure_packages('epel-release',{
+                ensure   => present,
+                provider => 'rpm',
+                source   => "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm",
+              })
+            }
+            default: { }
           }
           class { 'mysql::server::backup':
             backupuser          => 'myuser',
@@ -237,7 +287,7 @@ class { 'mysql::server::backup':
             backupdir           => '/tmp/xtrabackups',
             provider            => 'xtrabackup',
             incremental_backups => false,
-            execpath          => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
+            execpath            => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
           }
       MANIFEST
     it 'when configuring mysql backup' do

From dc43dd9d4b0eef0964e0192db674b62106e0aa92 Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Mon, 25 Nov 2019 00:19:14 +0100
Subject: [PATCH 07/12] MODULES-10023 fix xtrabackup tests on CentOS 6

---
 manifests/params.pp                          |  9 ++++++-
 spec/acceptance/mysql_backup_spec.rb         |  9 ++++---
 spec/classes/mysql_backup_xtrabackup_spec.rb | 28 +++++++++++++++++---
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/manifests/params.pp b/manifests/params.pp
index c143adf80..4af2ce159 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -37,7 +37,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 {
@@ -56,6 +56,7 @@
             $provider = 'mariadb'
           } else {
             $provider = 'mysql'
+            $xtrabackup_package_name_override = 'percona-xtrabackup-20'
           }
           if versioncmp($::operatingsystemmajrelease, '8') >= 0 {
             $java_package_name   = 'mariadb-java-client'
@@ -513,6 +514,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/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 8a88c8d8f..9171cfba0 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -203,7 +203,8 @@ class { 'mysql::server::backup':
     end
 
     it 'xtrabackup reports success for the full backup' do
-      run_shell('grep "completed OK" /tmp/xtrabackup_full.log') do |r|
+      # 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
@@ -223,7 +224,8 @@ class { 'mysql::server::backup':
     end
 
     it 'xtrabackup reports success for the incremental backup' do
-      run_shell('grep "completed OK" /tmp/xtrabackup_inc.log') do |r|
+      # 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
@@ -307,7 +309,8 @@ class { 'mysql::server::backup':
     end
 
     it 'xtrabackup reports success for the backup' do
-      run_shell('grep "completed OK" /tmp/xtrabackup.log') do |r|
+      # 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
diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb
index be920fae1..3d8044e6c 100644
--- a/spec/classes/mysql_backup_xtrabackup_spec.rb
+++ b/spec/classes/mysql_backup_xtrabackup_spec.rb
@@ -27,6 +27,16 @@ class { 'mysql::server': }
           )
         end
 
+        package = if facts[:osfamily] == 'RedHat'
+                    if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
+                      'percona-xtrabackup'
+                    else
+                      'percona-xtrabackup-20'
+                    end
+                  else
+                    'percona-xtrabackup'
+                  end
+
         it 'contains the weekly cronjob' do
           is_expected.to contain_cron('xtrabackup-weekly')
             .with(
@@ -37,7 +47,7 @@ class { 'mysql::server': }
               minute: '5',
               weekday: '0',
             )
-            .that_requires('Package[percona-xtrabackup]')
+            .that_requires("Package[#{package}]")
         end
 
         it 'contains the daily cronjob for weekdays 1-6' do
@@ -56,7 +66,7 @@ class { 'mysql::server': }
               minute: '5',
               weekday: '1-6',
             )
-            .that_requires('Package[percona-xtrabackup]')
+            .that_requires("Package[#{package}]")
         end
       end
 
@@ -90,6 +100,16 @@ 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], '7') >= 0
+                      'percona-xtrabackup'
+                    else
+                      'percona-xtrabackup-20'
+                    end
+                  else
+                    'percona-xtrabackup'
+                  end
+
         dateformat = case facts[:osfamily]
                      when 'FreeBSD', 'OpenBSD'
                        '$(date -v-sun +\%F)_full'
@@ -107,7 +127,7 @@ class { 'mysql::server': }
               minute: '5',
               weekday: '0',
             )
-            .that_requires('Package[percona-xtrabackup]')
+            .that_requires("Package[#{package}]")
         end
 
         it 'contains the daily cronjob for weekdays 1-6' do
@@ -120,7 +140,7 @@ class { 'mysql::server': }
               minute: '5',
               weekday: '1-6',
             )
-            .that_requires('Package[percona-xtrabackup]')
+            .that_requires("Package[#{package}]")
         end
       end
 

From 3e0e11af5f60870811d69f8500dd16b68bcb575f Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sun, 16 Feb 2020 18:33:29 +0100
Subject: [PATCH 08/12] MODULES-10023 fix xtrabackup tests on Debian 8, Ubuntu
 14.04, Scientific 6

---
 manifests/params.pp                          |  4 ++++
 spec/acceptance/mysql_backup_spec.rb         | 16 ++++++++++++++++
 spec/classes/mysql_backup_xtrabackup_spec.rb | 16 ++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/manifests/params.pp b/manifests/params.pp
index 4af2ce159..9999266bf 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -223,6 +223,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 ? {
diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 9171cfba0..48d4c66cc 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -153,6 +153,7 @@ class { 'mysql::server': root_password => 'password' }
                 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',
@@ -175,6 +176,13 @@ class { 'mysql::server': root_password => 'password' }
                 provider => 'rpm',
                 source   => "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm",
               })
+              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: { }
           }
@@ -258,6 +266,7 @@ class { 'mysql::server': root_password => 'password' }
                 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',
@@ -280,6 +289,13 @@ class { 'mysql::server': root_password => 'password' }
                 provider => 'rpm',
                 source   => "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm",
               })
+              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: { }
           }
diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb
index 3d8044e6c..66a8ba03c 100644
--- a/spec/classes/mysql_backup_xtrabackup_spec.rb
+++ b/spec/classes/mysql_backup_xtrabackup_spec.rb
@@ -33,6 +33,14 @@ class { 'mysql::server': }
                     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
                   else
                     'percona-xtrabackup'
                   end
@@ -106,6 +114,14 @@ class { 'mysql::server': }
                     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
                   else
                     'percona-xtrabackup'
                   end

From 5abb54d9cefda8074cc24a8c60392726066bc7d9 Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Wed, 26 Feb 2020 23:40:05 +0100
Subject: [PATCH 09/12] MODULES-10023 fix xtrabackup tests on SLES, RHEL 8 and
 RHEL/CentOS 5

---
 manifests/params.pp                          |  4 ++++
 spec/acceptance/mysql_backup_spec.rb         | 18 ++++++++++++++++--
 spec/classes/mysql_backup_xtrabackup_spec.rb | 12 ++++++++++--
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/manifests/params.pp b/manifests/params.pp
index 9999266bf..66ba18283 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -54,6 +54,9 @@
         /^(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'
@@ -153,6 +156,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 {
diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 48d4c66cc..6cf5f4377 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -166,10 +166,17 @@ class { 'mysql::server': root_password => 'password' }
               }
             }
             /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'
+              } else {
+                $percona_url = 'http://repo.percona.com/yum/release/5/os/noarch/percona-release-0.1-5.noarch.rpm'
+              }
               ensure_packages('percona-release',{
                 ensure   => present,
                 provider => 'rpm',
-                source   => 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm',
+                source   => $percona_url,
               })
               ensure_packages('epel-release',{
                 ensure   => present,
@@ -279,10 +286,17 @@ class { 'mysql::server': root_password => 'password' }
               }
             }
             /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'
+              } else {
+                $percona_url = 'http://repo.percona.com/yum/release/5/os/noarch/percona-release-0.1-5.noarch.rpm'
+              }
               ensure_packages('percona-release',{
                 ensure   => present,
                 provider => 'rpm',
-                source   => 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm',
+                source   => $percona_url,
               })
               ensure_packages('epel-release',{
                 ensure   => present,
diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb
index 66a8ba03c..a4daa2fba 100644
--- a/spec/classes/mysql_backup_xtrabackup_spec.rb
+++ b/spec/classes/mysql_backup_xtrabackup_spec.rb
@@ -28,7 +28,9 @@ class { 'mysql::server': }
         end
 
         package = if facts[:osfamily] == 'RedHat'
-                    if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
+                    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'
@@ -41,6 +43,8 @@ class { 'mysql::server': }
                     else
                       'percona-xtrabackup-24'
                     end
+                  elsif facts[:osfamily] == 'Suse'
+                    'xtrabackup'
                   else
                     'percona-xtrabackup'
                   end
@@ -109,7 +113,9 @@ class { 'mysql::server': }
         end
 
         package = if facts[:osfamily] == 'RedHat'
-                    if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
+                    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'
@@ -122,6 +128,8 @@ class { 'mysql::server': }
                     else
                       'percona-xtrabackup-24'
                     end
+                  elsif facts[:osfamily] == 'Suse'
+                    'xtrabackup'
                   else
                     'percona-xtrabackup'
                   end

From 3efa12355b87c1354a748f69abdd7f9db7c57eb1 Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sat, 29 Feb 2020 22:16:54 +0100
Subject: [PATCH 10/12] MODULES-10023 fix xtrabackup tests on RHEL/CentOS 5

---
 spec/acceptance/mysql_backup_spec.rb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 6cf5f4377..585185ff1 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -170,8 +170,10 @@ class { 'mysql::server': root_password => 'password' }
               # 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-5.noarch.rpm'
+                $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,
@@ -181,7 +183,7 @@ class { 'mysql::server': root_password => 'password' }
               ensure_packages('epel-release',{
                 ensure   => present,
                 provider => 'rpm',
-                source   => "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm",
+                source   => $epel_url,
               })
               if ($facts['os']['name'] == 'Scientific') {
                 # $releasever resolves to '6.10' instead of '6' which breaks Percona repos
@@ -290,8 +292,10 @@ class { 'mysql::server': root_password => 'password' }
               # 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-5.noarch.rpm'
+                $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,
@@ -301,7 +305,7 @@ class { 'mysql::server': root_password => 'password' }
               ensure_packages('epel-release',{
                 ensure   => present,
                 provider => 'rpm',
-                source   => "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm",
+                source   => $epel_url,
               })
               if ($facts['os']['name'] == 'Scientific') {
                 # $releasever resolves to '6.10' instead of '6' which breaks Percona repos

From 1f8eefc1a50a3a7964e3d3dd0ae89beb223eb302 Mon Sep 17 00:00:00 2001
From: Frank Wall <fw@moov.de>
Date: Sun, 29 Mar 2020 23:38:39 +0200
Subject: [PATCH 11/12] MODULES-10023 disable new xtrabackup tests on EOL
 operating systems

---
 spec/acceptance/mysql_backup_spec.rb | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 585185ff1..3d70ac320 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -136,7 +136,7 @@ class { 'mysql::server::backup':
 end
 
 context 'with xtrabackup enabled' do
-  context 'should work with no errors' 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 { [
@@ -208,7 +208,7 @@ class { 'mysql::server::backup':
     end
   end
 
-  describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') do
+  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
@@ -258,7 +258,7 @@ class { 'mysql::server::backup':
 end
 
 context 'with xtrabackup enabled and incremental backups disabled' do
-  context 'should work with no errors' 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 { [
@@ -331,7 +331,7 @@ class { 'mysql::server::backup':
     end
   end
 
-  describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') do
+  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

From 147239221c67aafdb4af3fb11b8e858b3c83bea6 Mon Sep 17 00:00:00 2001
From: sheena <sheena@puppet.com>
Date: Tue, 12 May 2020 13:03:15 +0100
Subject: [PATCH 12/12] (maint) exclude oracle6/centos6 platforms on running
 the feature tests

---
 spec/acceptance/mysql_backup_spec.rb | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb
index 3d70ac320..34080bdb2 100644
--- a/spec/acceptance/mysql_backup_spec.rb
+++ b/spec/acceptance/mysql_backup_spec.rb
@@ -136,7 +136,7 @@ class { 'mysql::server::backup':
 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
+  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 { [
@@ -208,7 +208,7 @@ class { 'mysql::server::backup':
     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
+  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
@@ -258,7 +258,7 @@ class { 'mysql::server::backup':
 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
+  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 { [
@@ -331,7 +331,7 @@ class { 'mysql::server::backup':
     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
+  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