From: Tom Hughes Date: Sun, 23 Jun 2013 17:39:50 +0000 (+0100) Subject: Bring otrs backup script undef chef control X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/298f0480877d5ac97a527c49a2ecf74b57a69024?ds=sidebyside;hp=c7ee9dcbb0d99cf3bbea9ae22e1de4111a8e58a8 Bring otrs backup script undef chef control --- 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