Puppet ethpad-lite DB backups.

Puppet will now add a cron job and configure logrotate to backup
etherpad-lite's MySQL DB daily and keep a months worth of backups.
These are the defaults and are slightly configurable through the
etherpad_lite::backup class.

Also configure log rotation for etherpad-lite's error.log and
access.log.

Change-Id: I30e0a4c8ee852e6621ee74744968d85696658608
This commit is contained in:
Clark Boylan 2012-06-04 21:49:48 +00:00
parent 9afce8412b
commit 7b299b2af1
4 changed files with 43 additions and 2 deletions
doc
manifests
modules/etherpad_lite/manifests

@ -374,8 +374,9 @@ MySQL
^^^^^
MySQL is configured by the Puppet module to allow user ``eplite`` to use
database ``etherpad-lite``. This module does not configure backups for the
``etherpad-lite`` database.
database ``etherpad-lite``. If you want backups for the ``etherpad-lite``
database you can include ``etherpad_lite::backup``. By default this will backup
the ``etherpad-lite`` DB daily and keep a rotation of 30 days of backups.
.. rubric:: Footnotes
.. [1] `Lodgeit homepage <http://www.pocoo.org/projects/lodgeit/>`_

@ -396,6 +396,7 @@ node 'etherpadlite.openstack.org' {
}
include etherpad_lite::site
include etherpad_lite::mysql
include etherpad_lite::backup
}
# A bare machine, but with a jenkins user

@ -0,0 +1,26 @@
class etherpad_lite::backup (
$minute = '0',
$hour = '0',
$day = '*',
$dest = "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/db.sql.gz",
$rotation = 'daily',
$num_backups = '30'
) {
cron { eplitedbbackup:
ensure => present,
command => "/usr/bin/mysqldump --defaults-file=/etc/mysql/debian.cnf --opt etherpad-lite | gzip -9 > ${dest}",
minute => $minute,
hour => $hour,
weekday => $day,
require => Package['mysql-server']
}
include logrotate
logrotate::file { 'eplitedb':
log => $dest,
options => ['nocompress', 'missingok', "rotate ${num_backups}", $rotation],
require => Cron['eplitedbbackup']
}
}

@ -38,4 +38,17 @@ class etherpad_lite::site (
require => Class['etherpad_lite']
}
include logrotate
logrotate::file { 'epliteerror':
log => "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/error.log",
options => ['compress', 'delaycompress', 'missingok', 'rotate 7', 'daily', 'notifempty'],
require => Service['etherpad-lite']
}
logrotate::file { 'epliteaccess':
log => "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/access.log",
options => ['compress', 'delaycompress', 'missingok', 'rotate 7', 'daily', 'notifempty'],
require => Service['etherpad-lite']
}
}