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

index f679ce82b7f39f6ec820fe9ef8598e40d596e176..66f4dd1fc01a558228dcd7025fde6b5d59ffb10a 100644 (file)
@@ -78,3 +78,10 @@ Dir.new(git_directory).select { |name| name =~ /\.git$/ }.each do |repository|
     end
   end
 end
     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 (file)
index 0000000..16f8559
--- /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 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