]> git.openstreetmap.org Git - chef.git/commitdiff
blogs: Add daily backup
authorGrant Slater <git@firefishy.com>
Fri, 22 Jul 2022 21:44:24 +0000 (00:44 +0300)
committerGrant Slater <git@firefishy.com>
Fri, 22 Jul 2022 21:44:24 +0000 (00:44 +0300)
cookbooks/blogs/recipes/default.rb
cookbooks/blogs/templates/default/backup.cron.erb [new file with mode: 0644]

index a3c8eebeeebadd6648fbdbc4d54ee9373aa951b2..e876c0a5c7f2d74bddf52b82000778ad80704e29 100644 (file)
@@ -27,6 +27,7 @@ package %W[
   gcc
   g++
   libsqlite3-dev
+  sqlite3
 ]
 
 directory "/srv/blogs.openstreetmap.org" do
@@ -83,3 +84,10 @@ cron_d "blogs" do
   command "/usr/local/bin/blogs-update"
   mailto "admins@openstreetmap.org"
 end
+
+template "/etc/cron.daily/blogs-backup" do
+  source "blogs-backup.erb"
+  owner "root"
+  group "root"
+  mode "0755"
+end
diff --git a/cookbooks/blogs/templates/default/backup.cron.erb b/cookbooks/blogs/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..382989a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp blogs.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=blogs-$D.tar.gz
+
+mkdir $T/blogs-$D
+sqlite3 /srv/blogs.openstreetmap.org/planet.db ".backup $T/blogs-$D/planet.db"
+
+export RSYNC_RSH="ssh -ax"
+
+nice tar --create --dereference --directory=$T blogs-$D | nice gzip --rsyncable -9 > $T/$B
+nice rsync --preallocate --fuzzy $T/$B backup::backup
+
+rm -rf $T