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

index 70213e899982afbd9511ce03d1b047db39419c7d..42cff06493bf8a8734a576e7ba15b68ede8a387d 100644 (file)
@@ -83,3 +83,10 @@ template "/etc/sudoers.d/trac" do
   group "root"
   mode 0440
 end
+
+template "/etc/cron.daily/trac-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
diff --git a/cookbooks/trac/templates/default/backup.cron.erb b/cookbooks/trac/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..06f6de9
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp trac.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=trac-$D.tar.gz
+
+trac-admin /var/lib/trac hotcopy $T/trac-$D > /dev/null
+
+export GZIP="--rsyncable -9"
+
+nice tar --create --gzip --directory=$T --file=$T/$B trac-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T