From 298f0480877d5ac97a527c49a2ecf74b57a69024 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 23 Jun 2013 18:39:50 +0100 Subject: [PATCH] Bring otrs backup script undef chef control --- cookbooks/otrs/recipes/default.rb | 7 +++++++ .../otrs/templates/default/backup.cron.erb | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 cookbooks/otrs/templates/default/backup.cron.erb diff --git a/cookbooks/otrs/recipes/default.rb b/cookbooks/otrs/recipes/default.rb index 731bdf273..55429af4d 100644 --- a/cookbooks/otrs/recipes/default.rb +++ b/cookbooks/otrs/recipes/default.rb @@ -142,3 +142,10 @@ template "/etc/sudoers.d/otrs" do 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 index 000000000..d377de86f --- /dev/null +++ b/cookbooks/otrs/templates/default/backup.cron.erb @@ -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 -- 2.39.5