]> git.openstreetmap.org Git - chef.git/commitdiff
Bring blog backup script under chef control
authorTom Hughes <tom@compton.nu>
Sun, 23 Jun 2013 18:07:05 +0000 (19:07 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 23 Jun 2013 18:11:00 +0000 (19:11 +0100)
cookbooks/foundation/recipes/default.rb
cookbooks/foundation/templates/default/backup.cron.erb [new file with mode: 0644]

index 7b1fa1d05c4293e8e3161ad84d7a5d66764d57a4..2f9b98849c3b75686f3eec7d8a2e1f11ad209dc7 100644 (file)
@@ -48,3 +48,11 @@ wordpress_plugin "sitepress-multilingual-cms" do
   site "blog.osmfoundation.org"
   source "plugins/sitepress-multilingual-cms"
 end
+
+template "/etc/cron.daily/blog-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0750
+  variable :passwords => passwords
+end
diff --git a/cookbooks/foundation/templates/default/backup.cron.erb b/cookbooks/foundation/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..6ab8a63
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp osm-blog.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=osm-blog-$D.tar.gz
+
+mkdir $T/osm-blog-$D
+mysqldump --user=osm-blog-user --password=<%= @passwords["osmf-blog-user"] %> --opt osm-blog > $T/osm-blog-$D/osm-blog.sql
+ln -s /srv/blog.openstreetmap.org $T/osm-blog-$D/www
+
+export GZIP="--rsyncable -9"
+
+nice tar --create --gzip --dereference --directory=$T --file=$T/$B osm-blog-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T