Add backups to lodgeit

Creates a git repo in /var/backups/lodgeit_db
Adds a backup file per installation in the repo
Adds a daily cron to take the backup and commit it in the repo

Change-Id: I9b4a684485bb37f3ae83b5aa39015c9489c29db4
This commit is contained in:
Andrew Hutchings 2012-02-01 15:12:45 +00:00
parent f5a1f59f5a
commit 76c625740b
2 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -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,