From: Tom Hughes Date: Thu, 20 Jun 2013 17:54:19 +0000 (+0100) Subject: Add a db::backup recipe to handle database backups X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/b890ca2b63073cca67e0f58620a05d2c28504c91 Add a db::backup recipe to handle database backups --- diff --git a/cookbooks/db/recipes/backup.rb b/cookbooks/db/recipes/backup.rb new file mode 100644 index 000000000..00da02911 --- /dev/null +++ b/cookbooks/db/recipes/backup.rb @@ -0,0 +1,32 @@ +# +# Cookbook Name:: db +# Recipe:: backup +# +# Copyright 2013, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +template "/usr/local/bin/backup-db" do + source "backup-db.erb" + owner "root" + group "root" + mode 0755 +end + +template "/etc/cron.d/backup-db" do + source "backup.cron.erb" + owner "root" + group "root" + mode 0644 +end diff --git a/cookbooks/db/templates/default/backup-db.erb b/cookbooks/db/templates/default/backup-db.erb new file mode 100644 index 000000000..3ad1020c4 --- /dev/null +++ b/cookbooks/db/templates/default/backup-db.erb @@ -0,0 +1,12 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +D=`date +%Y-%m-%d` +F=/tmp/osm-${D}.dmp + +pg_dump --user=backup --format=custom --file=$F openstreetmap + +rsync $F backup.openstreetmap.org::backup + +rm -f $F diff --git a/cookbooks/db/templates/default/backup.cron.erb b/cookbooks/db/templates/default/backup.cron.erb new file mode 100644 index 000000000..49f1ce1ca --- /dev/null +++ b/cookbooks/db/templates/default/backup.cron.erb @@ -0,0 +1,3 @@ +# DO NOT EDIT - This file is being maintained by Chef + +00 02 * * 1 osmbackup /usr/local/bin/backup-db diff --git a/roles/db-backup.rb b/roles/db-backup.rb new file mode 100644 index 000000000..6fab59d23 --- /dev/null +++ b/roles/db-backup.rb @@ -0,0 +1,14 @@ +name "db-backup" +description "Role applied to the server responsible for database backups" + +default_attributes( + :accounts => { + :users => { + :osmbackup => { :status => :role } + } + } +) + +run_list( + "recipe[db::backup]" +) diff --git a/roles/ramoth.rb b/roles/ramoth.rb index f93a38d58..17553f5d3 100644 --- a/roles/ramoth.rb +++ b/roles/ramoth.rb @@ -2,11 +2,6 @@ name "ramoth" description "Master role applied to ramoth" default_attributes( - :accounts => { - :users => { - :osmbackup => { :status => :role } - } - }, :db => { :cluster => "9.1/main" },