Elukey has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/364195 )

Change subject: role::piwik::server: add regular bacula backups
......................................................................


role::piwik::server: add regular bacula backups

Bug: T164073
Change-Id: Id35e45c1fa848c634b6dd893927b139276c66f35
---
A modules/profile/manifests/piwik/backup.pp
M modules/role/manifests/piwik/server.pp
2 files changed, 50 insertions(+), 1 deletion(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, but someone else must approve
  Elukey: Verified; Looks good to me, approved



diff --git a/modules/profile/manifests/piwik/backup.pp 
b/modules/profile/manifests/piwik/backup.pp
new file mode 100644
index 0000000..6183267
--- /dev/null
+++ b/modules/profile/manifests/piwik/backup.pp
@@ -0,0 +1,48 @@
+# == Class: profile::piwik::backup
+#
+# Periodical backups of the Piwik database tables using Bacula.
+#
+class profile::piwik::backup (
+    $backup_username    = hiera('profile::piwik::backup::username'),
+    $backup_password    = hiera('profile::piwik::backup::password'),
+    $retention_days     = 14,
+) {
+    include ::profile::backup::host
+
+    file { '/srv/backups':
+        ensure => directory,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0600', # implicitly 0700 for dirs
+    }
+
+    file { '/etc/mysql/conf.d/dumps.cnf':
+        ensure  => present,
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0400',
+        content => 
"[client]\nuser=${backup_username}\npassword=${backup_password}\n",
+    }
+
+    cron { 'delete_old_backups':
+        command => "/usr/bin/find /srv/backup -mtime +${retention_days} -exec 
/bin/rm {} \\;",
+        weekday => 0,
+        hour    => 0,
+        minute  => 0,
+        user    => 'root',
+    }
+
+    backup::mysqlset {'piwik':
+        xtrabackup       => false,
+        per_db           => true,
+        innodb_only      => true,
+        binlog           => false,
+        slave            => false,
+        local_dump_dir   => '/srv/backups',
+        password_file    => '/etc/mysql/conf.d/dumps.cnf',
+        method           => 'predump',
+        mysql_binary     => '/usr/bin/mysql',
+        mysqldump_binary => '/usr/bin/mysqldump',
+        jobdefaults      => 
"Weekly-${profile::backup::host::day}-${profile::backup::host::pool}",
+    }
+}
diff --git a/modules/role/manifests/piwik/server.pp 
b/modules/role/manifests/piwik/server.pp
index 2d4bbfe..61dee0d 100644
--- a/modules/role/manifests/piwik/server.pp
+++ b/modules/role/manifests/piwik/server.pp
@@ -4,9 +4,10 @@
     include ::standard
     include ::profile::piwik::webserver
     include ::profile::piwik::instance
+    # override profile::backup::enable to disable regular backups
+    include ::profile::piwik::backup
 
     # TODO - puppetization of mysql instance
-    # Ref: T159136
     require_package('mysql-server')
 
     system::role { 'piwik::server':

-- 
To view, visit https://gerrit.wikimedia.org/r/364195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id35e45c1fa848c634b6dd893927b139276c66f35
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Elukey <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Elukey <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to