heroku_s3_backup 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Eric Davis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "heroku_s3_backup"
8
+ gem.summary = %Q{Gem to backup your database on Heroku.com to S3.}
9
+ gem.description = %Q{http://almosteffortless.com/2010/04/14/automated-heroku-backups/}
10
+ gem.email = "edavis@littlestreamsoftware.com"
11
+ gem.homepage = "http://github.com/edavis10/heroku_s3_backup"
12
+ gem.authors = ["Eric Davis", "Trevor Turk"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency('right_aws', '~> 1.10')
15
+ gem.files = FileList[
16
+ "[A-Z]*",
17
+ "init.rb",
18
+ "rails/init.rb",
19
+ "{bin,generators,lib,test,app}/**/*",
20
+ 'lib/jeweler/templates/.gitignore'
21
+ ]
22
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
+ end
24
+ Jeweler::GemcutterTasks.new
25
+ rescue LoadError
26
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
27
+ end
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/test_*.rb'
41
+ test.verbose = true
42
+ end
43
+ rescue LoadError
44
+ task :rcov do
45
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
46
+ end
47
+ end
48
+
49
+ task :test => :check_dependencies
50
+
51
+ task :default => :test
52
+
53
+ require 'rake/rdoctask'
54
+ Rake::RDocTask.new do |rdoc|
55
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "heroku_s3_backup #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,19 @@
1
+ class HerokuS3Backup
2
+ def self.backup
3
+ begin
4
+ require 'right_aws'
5
+ puts "[#{Time.now}] heroku:backup started"
6
+ name = "#{ENV['APP_NAME']}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}.dump"
7
+ db = ENV['DATABASE_URL'].match(/postgres:\/\/([^:]+):([^@]+)@([^\/]+)\/(.+)/)
8
+ system "PGPASSWORD=#{db[2]} pg_dump -Fc --username=#{db[1]} --host=#{db[3]} #{db[4]} > tmp/#{name}"
9
+ s3 = RightAws::S3.new(ENV['s3_access_key_id'], ENV['s3_secret_access_key'])
10
+ bucket = s3.bucket("#{ENV['APP_NAME']}-heroku-backups", true, 'private')
11
+ bucket.put(name, open("tmp/#{name}"))
12
+ system "rm tmp/#{name}"
13
+ puts "[#{Time.now}] heroku:backup complete"
14
+ # rescue Exception => e
15
+ # require 'toadhopper'
16
+ # Toadhopper(ENV['hoptoad_key']).post!(e)
17
+ end
18
+ end
19
+ 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
+ HerokuS3Backup.backup
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'heroku_s3_backup'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestHerokuS3Backup < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heroku_s3_backup
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Eric Davis
13
+ - Trevor Turk
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-04-23 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: thoughtbot-shoulda
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: right_aws
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 10
43
+ version: "1.10"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ description: http://almosteffortless.com/2010/04/14/automated-heroku-backups/
47
+ email: edavis@littlestreamsoftware.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - LICENSE
54
+ - README.rdoc
55
+ files:
56
+ - LICENSE
57
+ - README.rdoc
58
+ - Rakefile
59
+ - VERSION
60
+ - lib/heroku_s3_backup.rb
61
+ - lib/tasks/heroku.rake
62
+ - test/helper.rb
63
+ - test/test_heroku_s3_backup.rb
64
+ has_rdoc: true
65
+ homepage: http://github.com/edavis10/heroku_s3_backup
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --charset=UTF-8
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.3.6
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Gem to backup your database on Heroku.com to S3.
94
+ test_files:
95
+ - test/helper.rb
96
+ - test/test_heroku_s3_backup.rb