]> git.openstreetmap.org Git - chef.git/commitdiff
Add backup script for prometheus
authorTom Hughes <tom@compton.nu>
Tue, 26 Jan 2021 18:30:43 +0000 (18:30 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 26 Jan 2021 18:30:43 +0000 (18:30 +0000)
cookbooks/backup/templates/default/expire.cron.erb
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/backup.cron.erb [new file with mode: 0644]

index a635d3358323687e1963993d4e8c4e49e246cf95..dc4f7e15ea74f394fc6d29a02f4c2a2bba6e5144 100644 (file)
@@ -2,7 +2,7 @@
 
 # DO NOT EDIT - This file is being maintained by Chef
 
-for prefix in chef-server chef-repository chef-git forum git lists munin osm-blog osm-donate osmf-crm osmf-ledgersmb wiki-wiki.osmfoundation.org osqa otrs sotm svn switch2osm trac wiki-board.osmfoundation.org wiki-dwg.osmfoundation.org wiki-mwg.osmfoundation.org wiki-wiki.openstreetmap.org
+for prefix in chef-server chef-repository chef-git forum git lists munin osm-blog osm-donate osmf-crm osmf-ledgersmb wiki-wiki.osmfoundation.org osqa otrs prometheus sotm svn switch2osm trac wiki-board.osmfoundation.org wiki-dwg.osmfoundation.org wiki-mwg.osmfoundation.org wiki-wiki.openstreetmap.org
 do
   /usr/local/bin/expire-backups --days=3 --weeks=3 --months=3 /store/backup $prefix
 done
index e4689dbf15346468154e4b3e8a2b73a51368369b..7e4f4b2bf9ee83a05c866901bad9f07df45cbf3a 100644 (file)
@@ -257,3 +257,10 @@ end
 apache_site "prometheus.openstreetmap.org" do
   template "apache.erb"
 end
+
+template "/etc/cron.daily/prometheus-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode "750"
+end
diff --git a/cookbooks/prometheus/templates/default/backup.cron.erb b/cookbooks/prometheus/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..3273aac
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp prometheus.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=prometheus-$D.tar.gz
+
+mkdir $T/prometheus-$D
+
+ln -s /var/lib/prometheus/alertmanager $T/prometheus-$D/alertmanager
+ln -s /var/lib/grafana $T/prometheus-$D/grafana
+
+export RSYNC_RSH="ssh -ax"
+
+nice tar --create --dereference --directory=$T prometheus-$D | nice gzip --rsyncable -9 > $T/$B
+nice rsync --preallocate --fuzzy $T/$B backup::backup
+
+rm -rf $T