Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
public redis dumps
Browse files Browse the repository at this point in the history
dwradcliffe committed Jul 23, 2015
1 parent 4027e1c commit 156b96a
Showing 5 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Berksfile.lock
Original file line number Diff line number Diff line change
@@ -241,7 +241,7 @@ GRAPH
chef-vault (>= 0.0.0)
nginx (>= 0.0.0)
runit (>= 0.0.0)
rubygems-backups (0.0.21)
rubygems-backups (0.0.24)
chef-vault (>= 0.0.0)
rubygems-ruby (>= 0.0.0)
rubygems-balancer (0.0.62)
2 changes: 1 addition & 1 deletion cookbooks/rubygems-backups/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name 'rubygems-backups'

version '0.0.21'
version '0.0.24'

depends 'chef-vault'
depends 'rubygems-ruby'
25 changes: 25 additions & 0 deletions cookbooks/rubygems-backups/recipes/redis.rb
Original file line number Diff line number Diff line change
@@ -32,3 +32,28 @@
command "backup perform --trigger redis --config-file #{File.join(node['rubygems']['backups']['config_dir'], 'redis.rb')}"
user 'root'
end

template File.join(node['rubygems']['backups']['config_dir'], 'public_redis.rb') do
source 'public_redis.rb.erb'
owner 'root'
group 'root'
mode 00600
variables(
aws_access_key: backup_secrets['aws_access_key'],
aws_secret_key: backup_secrets['aws_secret_key'],
bucket_name: 'rubygems-dumps',
slack_token: backup_secrets['slack_token']
)
end

cron 'redis-public-dump' do
hour '20'
minute '20'
day '*'
month '*'
weekday '1'
path '/usr/local/bin:/usr/bin:/bin'
command "backup perform --trigger public_redis --config-file #{File.join(node['rubygems']['backups']['config_dir'], 'public_redis.rb')}"
user 'root'
only_if { node.chef_environment == 'production' }
end
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ Backup::Model.new(:public_postgresql, 'RubyGems.org Public Database Dump') do
end

notify_by Slack do |slack|
slack.on_success = true
slack.on_success = false
slack.on_warning = true
slack.on_failure = true
slack.team = 'bundler'
38 changes: 38 additions & 0 deletions cookbooks/rubygems-backups/templates/default/public_redis.rb.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# encoding: utf-8

##
# Backup v4.x Configuration
#
# Documentation: http://meskyanichi.github.io/backup
# Issue Tracker: https://github.com/meskyanichi/backup/issues

require 'json'

Backup::Model.new(:public_redis, 'RubyGems.org Public Redis Dump') do

database Redis do |db|
db.rdb_path = '/var/lib/redis/dump-<%= node['redisio']['servers'][0]['port'] %>.rdb'
db.host = 'localhost'
db.port = <%= node['redisio']['servers'][0]['port'] %>
db.invoke_save = false
end

compress_with Gzip

store_with S3 do |s3|
s3.access_key_id = '<%= @aws_access_key %>'
s3.secret_access_key = '<%= @aws_secret_key %>'
s3.bucket = '<%= @bucket_name %>'
s3.region = 'us-west-2'
s3.path = '<%= node.chef_environment %>'
end

notify_by Slack do |slack|
slack.on_success = false
slack.on_warning = true
slack.on_failure = true
slack.team = 'bundler'
slack.token = '<%= @slack_token %>'
end

end

0 comments on commit 156b96a

Please sign in to comment.