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

index 1a52b9f426adcba3648a0531d254b16b83cbaab7..f9398d8cc06c19ecd0e72a1c94e25b171df05334 100644 (file)
@@ -48,3 +48,10 @@ apache_site site_name do
   directory repository_directory
   variables :realm => "Subversion Repository", :password_file => "/etc/apache2/svn.passwd"
 end
+
+template "/etc/cron.daily/svn-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
diff --git a/cookbooks/subversion/templates/default/backup.cron.erb b/cookbooks/subversion/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..ac3852a
--- /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 svn.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=svn-$D.tar.gz
+
+nice svnadmin hotcopy /var/lib/subversion/repos/openstreetmap $T/svn-$D > /dev/null
+
+export GZIP="--rsyncable -9"
+
+nice tar --create --gzip --directory=$T --file=$T/$B svn-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T