]> git.openstreetmap.org Git - chef.git/commitdiff
community: Add initial backup script
authorGrant Slater <git@firefishy.com>
Sat, 12 Mar 2022 00:19:34 +0000 (00:19 +0000)
committerGrant Slater <git@firefishy.com>
Sat, 12 Mar 2022 00:19:34 +0000 (00:19 +0000)
cookbooks/community/recipes/default.rb
cookbooks/community/templates/default/backup.cron.erb [new file with mode: 0644]

index dece2da1a979c417339da34e454561dda12dca08..5178f1617505d08483b91ef916eef4d7c65a0e34 100644 (file)
@@ -105,9 +105,10 @@ execute "discourse_container_mail_receiver_rebuild" do
   group "root"
 end
 
-## FIXME
-# Backup the backups
-# Maybe use /srv/community.openstreetmap.org/shared/web-only/backups/
-# Or https://github.com/discourse/discourse_docker/blob/8b0ae9b4da2f48d62d7a88035018dba403918325/templates/postgres.template.yml#L240
-#   and tar of the shared web uploads
-# https://github.com/discourse/discourse_docker/pull/611
+## FIXME https://github.com/discourse/discourse_docker/pull/611
+template "/etc/cron.daily/community-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode "750"
+end
diff --git a/cookbooks/community/templates/default/backup.cron.erb b/cookbooks/community/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..6945c3b
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp community.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=community-$D.tar.gz
+
+mkdir $T/commmunity-$D
+ln -s /srv/community.openstreetmap.org/docker/containers $T/commmunity-$D/containers
+ln -s /srv/community.openstreetmap.org/shared/web-only $T/commmunity-$D/shared-web-only
+ln -s /srv/community.openstreetmap.org/shared/data/redis_data $T/commmunity-$D/shared-data-redis_data
+ln -s /srv/community.openstreetmap.org/shared/data/postgres_backup $T/commmunity-$D/shared-data-postgres_backup
+
+export RSYNC_RSH="ssh -ax"
+
+nice tar --create --numeric-owner --dereference --directory=$T community-$D | nice gzip --rsyncable -9 > $T/$B
+nice rsync --preallocate --fuzzy $T/$B backup::backup
+
+rm -rf $T