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

index d394d7e580b1225d3e62f2be7bf0bc0c10d5c720..467f2b7b4737ba92295dd2bd685c73a45e07e366 100644 (file)
@@ -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 (file)
index 0000000..4a472e5
--- /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 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