jstorimer-heroku_s3_backup 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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.
data/README.rdoc ADDED
@@ -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.
data/Rakefile ADDED
@@ -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 -i --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
data/test/helper.rb ADDED
@@ -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,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jstorimer-heroku_s3_backup
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
10
+ platform: ruby
11
+ authors:
12
+ - Eric Davis
13
+ - Trevor Turk
14
+ - Jesse Storimer
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-04-23 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: thoughtbot-shoulda
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: right_aws
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 10
44
+ version: "1.10"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ description: http://almosteffortless.com/2010/04/14/automated-heroku-backups/
48
+ email: edavis@littlestreamsoftware.com
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ extra_rdoc_files:
54
+ - LICENSE
55
+ - README.rdoc
56
+ files:
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - VERSION
61
+ - lib/heroku_s3_backup.rb
62
+ - lib/tasks/heroku.rake
63
+ - test/helper.rb
64
+ - test/test_heroku_s3_backup.rb
65
+ has_rdoc: true
66
+ homepage: http://github.com/jstorimer/heroku_s3_backup
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --charset=UTF-8
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.6
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Gem to backup your database on Heroku.com to S3.
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/test_heroku_s3_backup.rb