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
diff --git a/manifests/backup.pp b/manifests/backup.pp
new file mode 100644
index 0000000..702b6ee
--- /dev/null
+++ b/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/manifests/site.pp b/manifests/site.pp
index 7efcfd9..1da83b2 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -38,4 +38,17 @@
     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']
+  }
+
 }