From: Tom Hughes Date: Sun, 23 Jun 2013 09:36:58 +0000 (+0100) Subject: Bring git backup script under chef control X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/5232219867a768acea6c943fdd99126a6d8f7098?ds=sidebyside Bring git backup script under chef control --- diff --git a/cookbooks/git/recipes/server.rb b/cookbooks/git/recipes/server.rb index f679ce82b..66f4dd1fc 100644 --- a/cookbooks/git/recipes/server.rb +++ b/cookbooks/git/recipes/server.rb @@ -78,3 +78,10 @@ Dir.new(git_directory).select { |name| name =~ /\.git$/ }.each do |repository| end end end + +template "/etc/cron.daily/git-backup" do + source "backup.cron.erb" + owner "root" + group "root" + mode 0755 +end diff --git a/cookbooks/git/templates/default/backup.cron.erb b/cookbooks/git/templates/default/backup.cron.erb new file mode 100644 index 000000000..16f85593b --- /dev/null +++ b/cookbooks/git/templates/default/backup.cron.erb @@ -0,0 +1,16 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +T=$(mktemp -d -t -p /var/tmp git.XXXXXXXXXX) +D=$(date +%Y-%m-%d) +B=git-$D.tar.gz + +ln -s /var/lib/git $T/git-$D + +export GZIP="--rsyncable -9" + +nice tar --create --gzip --dereference --directory=$T --file=$T/$B git-$D +nice rsync $T/$B backup::backup + +rm -rf $T