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

index 731bdf273a30deb9962652d0cd9fb7ed32c8bf11..55429af4d5d7cdda3c6d8b4d72d34cd5930502f5 100644 (file)
@@ -142,3 +142,10 @@ template "/etc/sudoers.d/otrs" do
   group "root"
   mode 0440
 end
   group "root"
   mode 0440
 end
+
+template "/etc/cron.daily/otrs-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
diff --git a/cookbooks/otrs/templates/default/backup.cron.erb b/cookbooks/otrs/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..d377de8
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp otrs.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=otrs-$D.tar.gz
+
+mkdir $T/otrs-$D
+chown otrs $T
+chown otrs $T/otrs-$D
+sudo -u otrs pg_dump --file=$T/otrs-$D/otrs.dmp otrs
+ln -s /opt/otrs $T/otrs-$D/otrs
+ln -s /etc/apache2/sites-available/otrs.openstreetmap.org $T/otrs-$D/apache2-otrs.openstreetmap.org
+
+export GZIP="--rsyncable -9"
+
+nice tar --create --gzip --dereference --directory=$T --file=$T/$B otrs-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T