heroku_pg_backups_archive 0.2.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48fbdd30064455891883b654824c26ae0237d56b
4
- data.tar.gz: 91d4801f52820bbfa478985707c443fad89eb187
3
+ metadata.gz: 85c8b0805d3fff81c92d1c13d66f52d9fad14a8e
4
+ data.tar.gz: d729910cf6a3d6ee98a66416df7ee1b0bf3f2464
5
5
  SHA512:
6
- metadata.gz: cf99909463923949105217050d3613e00f663b2ed574132008cdfc4730918a405d5626f6dbea6b23df1f08a9b62f5f9a058e207406c47d54626bd5597ea3bbef
7
- data.tar.gz: 1a06b3223635ca0b898130078cbdd2bc16f5ef43079e3aeb1a8abde7d125f73a9f5e02471d581b552948f0f3a43c40d3845d8101800813d8fdfdee61b37a47be
6
+ metadata.gz: 478c54c48298ca0be41b2146c17f1fe18bd50edb9a175bb26a3ff5154e1c423b633f38ecb0b24a488a7406b637ccf75034d51eda1cde2fd3d761a7b0576e310e
7
+ data.tar.gz: e4740766f316823196d2589ccec7a0e6680db6b0a0f44157f7dea3866714e25e25f814651e8ce695b6a897c30c35ec85f76795aa186bf89a34108cc5d0ef357b
@@ -2,7 +2,7 @@ require "heroku_pg_backups_archive/version"
2
2
  require "heroku_pg_backups_archive/config"
3
3
  require "heroku_pg_backups_archive/backup"
4
4
  require "heroku_pg_backups_archive/backup_archive"
5
- require "heroku_pg_backups_archive/backup_failed_error"
5
+ require "heroku_pg_backups_archive/operation_failed_error"
6
6
  require "heroku_pg_backups_archive/toolbelt_helper"
7
7
  require "heroku_pg_backups_archive/railtie"
8
8
 
@@ -25,9 +25,7 @@ module HerokuPgBackupsArchive
25
25
  private
26
26
 
27
27
  def extract_id(backup_output)
28
- matches = backup_output.match(/---backup---> (.*)\n/)
29
- raise BackupFailedError.new(backup_output) unless matches
30
- matches[1]
28
+ backup_output.match(/---backup---> (.*)\n/)[1]
31
29
  end
32
30
  end
33
31
  end
@@ -0,0 +1,4 @@
1
+ module HerokuPgBackupsArchive
2
+ class OperationFailedError < StandardError
3
+ end
4
+ end
@@ -1,5 +1,7 @@
1
1
  module HerokuPgBackupsArchive
2
2
  module ToolbeltHelper
3
+ RETRIES = 5
4
+
3
5
  class << self
4
6
  def capture_backup
5
7
  run("pg:backups capture -a #{HerokuPgBackupsArchive.config.app_name}")
@@ -18,9 +20,23 @@ module HerokuPgBackupsArchive
18
20
  def run(arguments)
19
21
  command = "#{HerokuPgBackupsArchive.config.heroku_toolbelt_path} #{arguments}"
20
22
  puts "Running: #{command}"
21
- output = `#{command}`
22
- puts "Output:\n#{output}"
23
- output
23
+
24
+ retries_remaining = RETRIES
25
+ begin
26
+ output = `#{command} 2>&1`
27
+ raise OperationFailedError.new(output) unless $?.success?
28
+ puts "Output:\n#{output}"
29
+ return output
30
+ rescue OperationFailedError => ex
31
+ retries_remaining -= 1
32
+ if retries_remaining > 0
33
+ puts "Failed, retrying..."
34
+ retry
35
+ else
36
+ puts "Still failing after #{RETRIES} retries, giving up."
37
+ raise ex
38
+ end
39
+ end
24
40
  end
25
41
  end
26
42
  end
@@ -1,3 +1,3 @@
1
1
  module HerokuPgBackupsArchive
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_pg_backups_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hightower
@@ -88,8 +88,8 @@ files:
88
88
  - lib/heroku_pg_backups_archive.rb
89
89
  - lib/heroku_pg_backups_archive/backup.rb
90
90
  - lib/heroku_pg_backups_archive/backup_archive.rb
91
- - lib/heroku_pg_backups_archive/backup_failed_error.rb
92
91
  - lib/heroku_pg_backups_archive/config.rb
92
+ - lib/heroku_pg_backups_archive/operation_failed_error.rb
93
93
  - lib/heroku_pg_backups_archive/railtie.rb
94
94
  - lib/heroku_pg_backups_archive/toolbelt_helper.rb
95
95
  - lib/heroku_pg_backups_archive/version.rb
@@ -1,4 +0,0 @@
1
- module HerokuPgBackupsArchive
2
- class BackupFailedError < StandardError
3
- end
4
- end