From b1c35e7b993b29d8212a0a98e810bbb1c710e319 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 23 Jun 2013 19:36:11 +0100 Subject: [PATCH] Bring switch2osm backup script under chef control --- cookbooks/switch2osm/recipes/default.rb | 8 ++++++++ .../templates/default/backup.cron.erb | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 cookbooks/switch2osm/templates/default/backup.cron.erb diff --git a/cookbooks/switch2osm/recipes/default.rb b/cookbooks/switch2osm/recipes/default.rb index d394d7e58..467f2b7b4 100644 --- a/cookbooks/switch2osm/recipes/default.rb +++ b/cookbooks/switch2osm/recipes/default.rb @@ -34,3 +34,11 @@ wordpress_theme "picolight" do repository "git://github.com/Firefishy/picolight-s2o.git" revision "master" end + +template "/etc/cron.daily/switch2osm-backup" do + source "backup.cron.erb" + owner "root" + group "root" + mode 0750 + variable :passwords => passwords +end diff --git a/cookbooks/switch2osm/templates/default/backup.cron.erb b/cookbooks/switch2osm/templates/default/backup.cron.erb new file mode 100644 index 000000000..4a472e5aa --- /dev/null +++ b/cookbooks/switch2osm/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 switch2osm.XXXXXXXXXX) +D=$(date +%Y-%m-%d) +B=switch2osm-$D.tar.gz + +mkdir $T/switch2osm-$D +mysqldump --user=switch2osm-user --password=<%= @passwords["switch2osm-user"] %> --opt switch2osm-blog > $T/switch2osm-$D/switch2osm-blog.sql +ln -s /srv/switch2osm.org $T/switch2osm-$D/www + +export GZIP="--rsyncable -9" + +nice tar --create --gzip --dereference --directory=$T --file=$T/$B switch2osm-$D +nice rsync $T/$B backup::backup + +rm -rf $T -- 2.39.5