heroku-s3-backup-zinergia 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in heroku-s3-backup-zinergia.gemspec
4
+ gemspec
@@ -0,0 +1,31 @@
1
+ = heroku_s3_backup
2
+
3
+ Gem to backup your database on Heroku.com to S3.
4
+
5
+ == Usage
6
+
7
+ 1. Add the heroku_s3_backup gem to your .gems file for Heroku
8
+ 2. Add your S3 config to Heroku
9
+ heroku config:add s3_access_key_id=YOUR_ID s3_secret_access_key=YOUR_KEY
10
+ 3. Run the HerokuS3Backup.backup method from your console or a cronjob
11
+ task :cron => :environment do
12
+ HerokuS3Backup.backup
13
+ end
14
+
15
+ The blog post at http://almosteffortless.com/2010/04/14/automated-heroku-backups/ has some more detailed instructions.
16
+
17
+ == Note on Patches/Pull Requests
18
+
19
+ * Fork the project.
20
+ * Make your feature addition or bug fix.
21
+ * Add tests for it. This is important so I don't break it in a
22
+ future version unintentionally.
23
+ * Commit, do not mess with rakefile, version, or history.
24
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
25
+ * Send me a pull request. Bonus points for topic branches.
26
+
27
+ == Copyright
28
+
29
+ Code stolen from Trevor Turk (http://almosteffortless.com/2010/04/14/automated-heroku-backups/) and packaged by Eric Davis.
30
+
31
+ Copyright (c) 2010 Eric Davis. See LICENSE for details.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "heroku-s3-backup-zinergia/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "heroku-s3-backup-zinergia"
7
+ s.version = Heroku::S3::Backup::Zinergia::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Eric Davis", "Trevor Turk", "Nicolás Hock"]
10
+ s.email = ["nhocki@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Backup your heroku database to S3 without suffering}
13
+ s.description = %q{Backup your heroku database to S3 without suffering. Based on http://almosteffortless.com/2010/04/14/automated-heroku-backups/}
14
+
15
+ s.rubyforge_project = "heroku-s3-backup-zinergia"
16
+
17
+ s.add_dependency('right_aws', '>= 2.1.0')
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,20 @@
1
+ class HerokuDatabaseBackupToS3
2
+ def self.backup
3
+ begin
4
+ require 'digest/md5'
5
+ require 'right_aws'
6
+ puts "[#{Time.now}] heroku:backup started"
7
+ name = "#{ENV['APP_NAME']}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}.dump"
8
+ db = ENV['DATABASE_URL'].match(/postgres:\/\/([^:]+):([^@]+)@([^\/]+)\/(.+)/)
9
+ system "PGPASSWORD=#{db[2]} pg_dump -Fc --username=#{db[1]} --host=#{db[3]} #{db[4]} > tmp/#{name}"
10
+ s3 = RightAws::S3.new(ENV['s3_access_key_id'], ENV['s3_secret_access_key'])
11
+ bucket = s3.bucket("#{ENV['APP_NAME']}-heroku-backups", true, 'private')
12
+ bucket.put(name, open("tmp/#{name}"))
13
+ system "rm tmp/#{name}"
14
+ puts "[#{Time.now}] heroku:backup complete"
15
+ # rescue Exception => e
16
+ # require 'toadhopper'
17
+ # Toadhopper(ENV['hoptoad_key']).post!(e)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ module Heroku
2
+ module S3
3
+ module Backup
4
+ module Zinergia
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ namespace :heroku do
2
+ desc "Example showing PostgreSQL database backups from Heroku to Amazon S3"
3
+ task :backup => :environment do
4
+ HerokuDatabaseBackupToS3.backup
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heroku-s3-backup-zinergia
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Eric Davis
9
+ - Trevor Turk
10
+ - "Nicol\xC3\xA1s Hock"
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2011-04-24 00:00:00 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: right_aws
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 2.1.0
26
+ type: :runtime
27
+ version_requirements: *id001
28
+ description: Backup your heroku database to S3 without suffering. Based on http://almosteffortless.com/2010/04/14/automated-heroku-backups/
29
+ email:
30
+ - nhocki@gmail.com
31
+ executables: []
32
+
33
+ extensions: []
34
+
35
+ extra_rdoc_files: []
36
+
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - README.rdoc
41
+ - Rakefile
42
+ - heroku-s3-backup-zinergia.gemspec
43
+ - lib/heroku-s3-backup-zinergia.rb
44
+ - lib/heroku-s3-backup-zinergia/version.rb
45
+ - lib/tasks/heroku.rake
46
+ homepage: ""
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project: heroku-s3-backup-zinergia
69
+ rubygems_version: 1.7.2
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Backup your heroku database to S3 without suffering
73
+ test_files: []
74
+
75
+ has_rdoc: