From: Tom Hughes Date: Sun, 23 Jun 2013 18:38:42 +0000 (+0100) Subject: Bring thinkup backup script under chef control X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/9532639f55150f23cc8dff77c01a78a06c6db32b?ds=sidebyside Bring thinkup backup script under chef control --- diff --git a/cookbooks/thinkup/recipes/default.rb b/cookbooks/thinkup/recipes/default.rb index ab85e645e..09b49db2e 100644 --- a/cookbooks/thinkup/recipes/default.rb +++ b/cookbooks/thinkup/recipes/default.rb @@ -114,3 +114,11 @@ template "/etc/cron.d/thinkup" do group "root" mode "0644" end + +template "/etc/cron.daily/thinkup-backup" do + source "backup.cron.erb" + owner "root" + group "root" + mode 0750 + variable :passwords => passwords +end diff --git a/cookbooks/thinkup/templates/default/backup.cron.erb b/cookbooks/thinkup/templates/default/backup.cron.erb new file mode 100644 index 000000000..b5b6c75bb --- /dev/null +++ b/cookbooks/thinkup/templates/default/backup.cron.erb @@ -0,0 +1,18 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +T=$(mktemp -d -t -p /var/tmp thinkup.XXXXXXXXXX) +D=$(date +%Y-%m-%d) +B=thinkup-$D.tar.gz + +mkdir $T/thinkup-$D +mysqldump --user=thinkup --password=<% @passwords["database"] %> --opt thinkup > $T/thinkup-$D/thinkup.sql +ln -s /srv/thinkup.openstreetmap.org $T/thinkup-$D/www + +export GZIP="--rsyncable -9" + +nice tar --create --gzip --dereference --directory=$T --file=$T/$B thinkup-$D +nice rsync $T/$B backup::backup + +rm -rf $T