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:
parent
b0ae2fea97
commit
06e8179c7e
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user