donate: add backup script
authorGrant Slater <git@firefishy.com>
Sun, 2 Oct 2016 00:03:16 +0000 (01:03 +0100)
committerGrant Slater <git@firefishy.com>
Sun, 2 Oct 2016 00:03:16 +0000 (01:03 +0100)
cookbooks/donate/templates/default/backup.cron.erb

index 6e82ad0..139c1a3 100644 (file)
@@ -1,3 +1,19 @@
+#!/bin/sh
+
 # DO NOT EDIT - This file is being maintained by Chef
 
-# FIXME to follow
+T=$(mktemp -d -t -p /var/tmp osm-donate.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=osm-donate-$D.tar.gz
+
+mkdir $T/osm-donate-$D
+mysqldump --user=donate --password="<%= @passwords['database'] %>" --opt donate > $T/osm-donate-$D/osm-donate.sql
+ln -s /srv/donate.openstreetmap.org $T/osm-donate-$D/www
+
+export GZIP="--rsyncable -9"
+export RSYNC_RSH="ssh -ax"
+
+nice tar --create --gzip --dereference --directory=$T --file=$T/$B osm-donate-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T