awesome_backup 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8adf991524a36db67665ca7b5b979450694d83f4b84b7b872108f296f72849e
4
- data.tar.gz: 77a57034104bac734982dcb4ad7e9c242168031a0de3d0b995a8fee7612d6601
3
+ metadata.gz: f4588641c8aae8f2c87f4c76e9d84daf09b070f5aba36b781e419608817fe8f3
4
+ data.tar.gz: 7f82d8d87b3e25413319c3c6977b89f5f91776d4b8ad6c172ace1cfd4b460065
5
5
  SHA512:
6
- metadata.gz: 5eccebb1aeda734740ac0b3e4778006cc75197f71ea40bb89a81d413db3e3e598a835216ec978f5a1ee498a712d038986e2a60225fdf8df2342d179cfa06c036
7
- data.tar.gz: 44bbd200454d3b122ee929bcf90f762022b1253586f185e73c6012cf2b78bb21ef69dcafd004c3b2638de521646b300ba646b2306d058568d47de2bd61462229
6
+ metadata.gz: 68ca5afd2fbcc7778535a47e76967f48df0aed5bec611f4c2414895774cac1601347ec253ce93a1e21545ddc8f345277b574f244e34852167b0677d4b2a98250
7
+ data.tar.gz: 1580efb82ae1fc05df6d4287430bd17e7d93350224cf12ae313181a4a04f54d11e5e8d6395dd0470971210904b83f9f009f0645a94d5e8caa72945e6dedc1c7d
@@ -1,20 +1,24 @@
1
1
  require "English"
2
2
 
3
3
  class AwesomeBackup::PostgresBackupService < AwesomeBackup::ApplicationService
4
- def execute
5
- result = `#{pg_dump_command} > \"#{tempfile_path}\"`
6
- raise "Command failed: #{result}" unless $CHILD_STATUS.exitstatus.zero?
4
+ def perform
5
+ run_command("#{pg_dump_command} > \"#{tempfile_path}\"")
6
+ attach_file
7
+ succeed!(backup: backup)
8
+ end
7
9
 
8
- backup = AwesomeBackup::PostgresBackup.create!
10
+ private
11
+
12
+ def attach_file
9
13
  backup.file.attach(
10
14
  io: File.open(tempfile_path),
11
15
  filename: "database.dump"
12
16
  )
13
-
14
- succeed!(backup: backup)
15
17
  end
16
18
 
17
- private
19
+ def backup
20
+ @backup ||= AwesomeBackup::PostgresBackup.create!
21
+ end
18
22
 
19
23
  def database_config
20
24
  @database_config ||= Rails.configuration.database_configuration.fetch(Rails.env)
@@ -48,6 +52,13 @@ private
48
52
  " -U \"#{database_config.fetch("username")}\"" if database_config["username"].present?
49
53
  end
50
54
 
55
+ def run_command(command)
56
+ result = `#{command}`
57
+ raise "Command failed: #{result}" unless $CHILD_STATUS.exitstatus.zero?
58
+
59
+ result
60
+ end
61
+
51
62
  def tempfile_path
52
63
  @tempfile_path ||= "#{Dir.tmpdir}/#{SecureRandom.hex}.dump"
53
64
  end
@@ -1,3 +1,3 @@
1
1
  module AwesomeBackup
2
- VERSION = "0.0.0".freeze
2
+ VERSION = "0.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2021-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -205,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
- version: '0'
208
+ version: '2.5'
209
209
  required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  requirements:
211
211
  - - ">="
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  requirements: []
215
- rubygems_version: 3.0.6
215
+ rubygems_version: 3.0.8
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Make backups of your stuff in a simple way.