diff --git a/doc/puppet_modules.rst b/doc/puppet_modules.rst index 0d83754956..853522b1fb 100644 --- a/doc/puppet_modules.rst +++ b/doc/puppet_modules.rst @@ -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 `_ diff --git a/manifests/site.pp b/manifests/site.pp index 6d0657d367..d031ddb476 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -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 diff --git a/modules/etherpad_lite/manifests/backup.pp b/modules/etherpad_lite/manifests/backup.pp new file mode 100644 index 0000000000..702b6ee482 --- /dev/null +++ b/modules/etherpad_lite/manifests/backup.pp @@ -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'] + } + +} diff --git a/modules/etherpad_lite/manifests/site.pp b/modules/etherpad_lite/manifests/site.pp index 7efcfd92b5..1da83b2549 100644 --- a/modules/etherpad_lite/manifests/site.pp +++ b/modules/etherpad_lite/manifests/site.pp @@ -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'] + } + }