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

index 13b05afcfa7f6cfa9d34c75b57e5aa5e690207a9..116f5c8bebea1f5e37c3276ea3db3c6e8543c324 100644 (file)
@@ -156,3 +156,11 @@ directory "/data/crm.osmfoundation.org/civicrm/en_US/ConfigAndLog" do
   group "www-data"
   mode "0775"
 end
+
+template "/etc/cron.daily/osmf-crm-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0750
+  variable :passwords => passwords
+end
diff --git a/cookbooks/civicrm/templates/default/backup.cron.erb b/cookbooks/civicrm/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..55657a6
--- /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 osmf-crm.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=osmf-crm-$D.tar.gz
+
+mkdir $T/osmf-crm-$D
+mysqldump --user=civicrm --password=<%= @passwords["database"] %> --opt --skip-lock-tables civicrm > $T/osmf-crm-$D/civicrm.sql
+ln -s /data/crm.osmfoundation.org $T/osmf-crm-$D/www
+
+export GZIP="--rsyncable -9"
+
+nice tar --create --gzip --dereference --directory=$T --file=$T/$B osmf-crm-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T