heroku_backup_task 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # heroku\_backup\_task
2
+
3
+ ## Description
4
+
5
+ A simple helper to automate your [Heroku](http://heroku.com) app [backups](http://addons.heroku.com/pgbackups)
6
+
7
+ ## Installation
8
+
9
+ # Gemfile
10
+ gem "heroku_backup_task"
11
+
12
+ # Rakefile
13
+ require "heroku_backup_task/tasks"
14
+ task :cron => :heroku_backup
15
+
16
+ # Rakefile (alternative)
17
+ require "heroku_backup_task"
18
+ task :cron do
19
+ # other code here
20
+ HerokuBackupTask.execute
21
+ end
22
+
23
+ Make sure you install the pgbackups addon
24
+
25
+ heroku addons:add pgbackups:basic
26
+
27
+ ## Configuration
28
+
29
+ By default, `heroku_backup_task` will back up `DATABASE_URL`. You can change this with:
30
+
31
+ heroku config:add HEROKU_BACKUP_DATABASES="SOME_DATABASE_URL,OTHER_DATABASE_URL"
32
+
33
+ ## Usage
34
+
35
+ ### NOTE: `heroku_backup_task` will expire your oldest backup to make room for a new backup if necessary.
36
+
37
+ Set up cron on your application with
38
+
39
+ heroku addons:add cron:daily
40
+
41
+ You will see something like this in your cron logs
42
+
43
+ [Thu Nov 18 12:59:56 -0500 2010] starting heroku backup task
44
+ [Thu Nov 18 12:59:57 -0500 2010] backing up: DATABASE_URL
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,42 @@
1
+ require "heroku"
2
+ require "pgbackups/client"
3
+
4
+ module HerokuBackupTask; class << self
5
+
6
+ def log(message)
7
+ puts "[#{Time.now}] #{message}"
8
+ end
9
+
10
+ def backups_url
11
+ ENV["PGBACKUPS_URL"]
12
+ end
13
+
14
+ def client
15
+ @client ||= PGBackups::Client.new(ENV["PGBACKUPS_URL"])
16
+ end
17
+
18
+ def databases
19
+ if db = ENV["HEROKU_BACKUP_DATABASES"]
20
+ db.split(",").map(&:strip)
21
+ else
22
+ ["DATABASE_URL"]
23
+ end
24
+ end
25
+
26
+ def backup_name(to_url)
27
+ # translate s3://bucket/email/foo/bar.dump => foo/bar
28
+ parts = to_url.split('/')
29
+ parts.slice(4..-1).join('/').gsub(/\.dump$/, '')
30
+ end
31
+
32
+ def execute
33
+ log "starting heroku backup task"
34
+
35
+ databases.each do |db|
36
+ db_url = ENV[db]
37
+ log "backing up: #{db}"
38
+ client.create_transfer(db_url, db, nil, "BACKUP", :expire => true)
39
+ end
40
+ end
41
+
42
+ end; end
@@ -0,0 +1,5 @@
1
+ require "heroku_backup_task"
2
+
3
+ task :heroku_backup do
4
+ HerokuBackupTask.execute
5
+ end
@@ -0,0 +1,3 @@
1
+ module HerokuBackupTask
2
+ VERSION = "0.0.3"
3
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_backup_task
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Dollar
@@ -56,8 +56,11 @@ extensions: []
56
56
 
57
57
  extra_rdoc_files: []
58
58
 
59
- files: []
60
-
59
+ files:
60
+ - lib/heroku_backup_task/tasks.rb
61
+ - lib/heroku_backup_task/version.rb
62
+ - lib/heroku_backup_task.rb
63
+ - README.md
61
64
  has_rdoc: true
62
65
  homepage: http://github.com/ddollar/heroku_backup_task
63
66
  licenses: []