diff --git a/modules/lodgeit/manifests/init.pp b/modules/lodgeit/manifests/init.pp index 87a1e15b1d..abcd661c6a 100644 --- a/modules/lodgeit/manifests/init.pp +++ b/modules/lodgeit/manifests/init.pp @@ -45,6 +45,14 @@ class lodgeit { onlyif => "test ! -d /tmp/lodgeit-main" } +# create initial git DB backup location + + exec { "create_db_backup": + command => "git init /var/backups/lodgeit_db", + path => "/bin:/usr/bin", + onlyif => "test ! -d /var/backups/lodgeit_db" + } + service { 'nginx': ensure => running, hasrestart => true diff --git a/modules/lodgeit/manifests/site.pp b/modules/lodgeit/manifests/site.pp index 7786e85857..144012ccda 100644 --- a/modules/lodgeit/manifests/site.pp +++ b/modules/lodgeit/manifests/site.pp @@ -50,6 +50,24 @@ define lodgeit::site($port, $image="") { require => Service["drizzle"] } +# create a backup .sql file in git + + exec { "create_db_backup_${name}": + command => "touch ${name}.sql && git add ${name}.sql && git commit -am \"Initial commit for ${name}\"", + cwd => "/var/backups/lodgeit_db/", + path => "/bin:/usr/bin", + onlyif => "test ! -f /var/backups/lodgeit_db/${name}.sql" + } + +# cron to take a backup and commit it in git + + cron { "update_backup_${name}": + user => root, + hour => 6, + minute => 23, + command => "sleep $((RANDOM%60+60)) && cd /var/backups/lodgeit_db && drizzledump -uroot ${name} > ${name}.sql && git commit -am \"Updating DB backup for ${name}\"" + } + service { "${name}-paste": provider => upstart, ensure => running,