heroku-s3-backup-zinergia 0.0.1 → 0.0.2
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/README.rdoc +16 -13
- data/heroku-s3-backup-zinergia.gemspec +1 -1
- data/lib/heroku-s3-backup-zinergia.rb +19 -8
- data/lib/heroku-s3-backup-zinergia/version.rb +1 -1
- data/lib/tasks/heroku.rake +1 -0
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -1,31 +1,34 @@
|
|
1
|
-
=
|
1
|
+
= Heroku S3 Backup (Zinergia's version)
|
2
2
|
|
3
|
-
Gem to backup your database on Heroku.com to S3.
|
3
|
+
Gem to backup postgress your database on Heroku.com to S3.
|
4
|
+
|
5
|
+
This was copied from https://github.com/edavis10/heroku_s3_backup but we added support for Ruby 1.9.2 and also used Bundler for the gem management (it's much cleaner).
|
6
|
+
|
7
|
+
Other than that, it's the same...
|
4
8
|
|
5
9
|
== Usage
|
6
10
|
|
7
|
-
1. Add the
|
11
|
+
1. Add the 'heroku-s3-backup-zinergia' gem to your Gemfile for Heroku
|
12
|
+
|
8
13
|
2. Add your S3 config to Heroku
|
14
|
+
|
9
15
|
heroku config:add s3_access_key_id=YOUR_ID s3_secret_access_key=YOUR_KEY
|
16
|
+
|
10
17
|
3. Run the HerokuS3Backup.backup method from your console or a cronjob
|
18
|
+
|
11
19
|
task :cron => :environment do
|
12
|
-
|
20
|
+
require 'heroku-s3-backup-zinergia'
|
21
|
+
HerokuDatabaseBackupToS3.backup
|
13
22
|
end
|
14
23
|
|
15
24
|
The blog post at http://almosteffortless.com/2010/04/14/automated-heroku-backups/ has some more detailed instructions.
|
16
25
|
|
17
|
-
==
|
26
|
+
== Patches/Pull Requests
|
18
27
|
|
19
|
-
|
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.
|
28
|
+
Everything it's welcome. But please, if you'll edit the version file, make that a separate commit. That way I can edit that if needed.
|
26
29
|
|
27
30
|
== Copyright
|
28
31
|
|
29
32
|
Code stolen from Trevor Turk (http://almosteffortless.com/2010/04/14/automated-heroku-backups/) and packaged by Eric Davis.
|
30
33
|
|
31
|
-
Copyright (c)
|
34
|
+
Copyright (c) 2011 Zinergia. Released under the MIT License
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = "heroku-s3-backup-zinergia"
|
16
16
|
|
17
|
-
s.add_dependency('
|
17
|
+
s.add_dependency('aws-s3', '~> 0.6.2')
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,20 +1,31 @@
|
|
1
1
|
class HerokuDatabaseBackupToS3
|
2
|
+
|
3
|
+
def self.create_bucket_if_it_does_not_exist(bucket_name)
|
4
|
+
AWS::S3::Bucket.find(bucket_name)
|
5
|
+
rescue AWS::S3::NoSuchBucket => e
|
6
|
+
puts "Bucket '#{bucket_name}' does not exist. Creating it..."
|
7
|
+
AWS::S3::Bucket.create(bucket_name)
|
8
|
+
end
|
9
|
+
|
2
10
|
def self.backup
|
3
11
|
begin
|
4
|
-
require '
|
5
|
-
require 'right_aws'
|
12
|
+
require 'aws/s3'
|
6
13
|
puts "[#{Time.now}] heroku:backup started"
|
7
14
|
name = "#{ENV['APP_NAME']}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}.dump"
|
8
15
|
db = ENV['DATABASE_URL'].match(/postgres:\/\/([^:]+):([^@]+)@([^\/]+)\/(.+)/)
|
9
16
|
system "PGPASSWORD=#{db[2]} pg_dump -Fc --username=#{db[1]} --host=#{db[3]} #{db[4]} > tmp/#{name}"
|
10
|
-
|
11
|
-
|
12
|
-
|
17
|
+
bucket_name = "#{ENV['APP_NAME']}-heroku-backups"
|
18
|
+
create_bucket_if_it_does_not_exist(bucket_name)
|
19
|
+
|
20
|
+
AWS::S3::S3Object.store(name, open("tmp/#{name}"),
|
21
|
+
bucket_name,
|
22
|
+
:access => :private)
|
23
|
+
|
24
|
+
# s3 = RightAws::S3.new(ENV['s3_access_key_id'], ENV['s3_secret_access_key'])
|
25
|
+
# bucket = s3.bucket("#{ENV['APP_NAME']}-heroku-backups", true, 'private')
|
26
|
+
# bucket.put(name, open("tmp/#{name}"))
|
13
27
|
system "rm tmp/#{name}"
|
14
28
|
puts "[#{Time.now}] heroku:backup complete"
|
15
|
-
# rescue Exception => e
|
16
|
-
# require 'toadhopper'
|
17
|
-
# Toadhopper(ENV['hoptoad_key']).post!(e)
|
18
29
|
end
|
19
30
|
end
|
20
31
|
end
|
data/lib/tasks/heroku.rake
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: heroku-s3-backup-zinergia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eric Davis
|
@@ -12,17 +12,17 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2011-
|
15
|
+
date: 2011-05-11 00:00:00 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
|
-
name:
|
18
|
+
name: aws-s3
|
19
19
|
prerelease: false
|
20
20
|
requirement: &id001 !ruby/object:Gem::Requirement
|
21
21
|
none: false
|
22
22
|
requirements:
|
23
|
-
- -
|
23
|
+
- - ~>
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 0.6.2
|
26
26
|
type: :runtime
|
27
27
|
version_requirements: *id001
|
28
28
|
description: Backup your heroku database to S3 without suffering. Based on http://almosteffortless.com/2010/04/14/automated-heroku-backups/
|