capistrano-ops 0.2.5 → 0.2.6

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: 9ff5391932b65811de3330a802d309df6d78dc1d2b6b04cc60b5c86dfe0de6e1
4
- data.tar.gz: 769c58ef06c175441bc53a673ee379394fc343cfdfe37612999b204508db742d
3
+ metadata.gz: 1ddab185886973237cac8aab6671b9bb580d5496f72e37f0678b6b0dd794c78a
4
+ data.tar.gz: 4c12ffe04071978d364f6a02b5d0cfd3a0e651a8669b86c00e2445c1830bc74b
5
5
  SHA512:
6
- metadata.gz: e2e68e6ebb4da63511fe2a8712eeee07368b3ab6f427faa0be00799784ba73aa67eb49787d6c09f67a6da9dd6dda08e0c57296e3b1f621505e5db40576aaab1a
7
- data.tar.gz: 0752765d093c875d5d96eb7b32451dc38a2f15519920f1bf85ebb1c6c926e4161e7e9488f681ee0d2067ca22b0192efab994e3ae268a55521b8789b7bc077b93
6
+ metadata.gz: 36dc0e5814ab7ff1b7370b366cf8dce0f8c4092f300319c7d2f936c554455ad7bd1edb5e519c80157515f0590d55ca4f995f9dbbadcd72d7803040e7c4ffb5bd
7
+ data.tar.gz: e2a9c85b8a361cca26a84bdade6500d31f8ab63e3f792e002dd7db5b3949779eb9fbfe5fccad7496fc4baff6baa7dbb3c6921e933ca7dd11a3f3ba61ca83bec0
@@ -11,13 +11,13 @@ module Backup
11
11
  self.region = region
12
12
  self.access_key_id = access_key_id
13
13
  self.secret_access_key = secret_access_key
14
- config = {
14
+ configuration = {
15
15
  region: region,
16
16
  access_key_id: access_key_id,
17
17
  secret_access_key: secret_access_key
18
18
  }
19
- config[:endpoint] = endpoint unless endpoint.nil?
20
- self.s3_resource = Aws::S3::Resource.new(config)
19
+ configuration[:endpoint] = endpoint unless endpoint.nil?
20
+ self.s3_resource = Aws::S3::Resource.new(configuration)
21
21
  end
22
22
 
23
23
  def upload(backup_file, key)
@@ -5,9 +5,9 @@ namespace :pg do
5
5
  include PostgresHelper
6
6
 
7
7
  task :dump do
8
- backup_path = config[:backup_path]
9
- backups_enabled = config[:backups_enabled]
10
- external_backup = config[:external_backup]
8
+ backup_path = configuration[:backup_path]
9
+ backups_enabled = configuration[:backups_enabled]
10
+ external_backup = configuration[:external_backup]
11
11
 
12
12
  unless backups_enabled
13
13
  puts 'dump: Backups are disabled'
@@ -15,7 +15,7 @@ namespace :pg do
15
15
  end
16
16
 
17
17
  notification = Notification::Api.new
18
- commandlist = dump_cmd(config)
18
+ commandlist = dump_cmd(configuration)
19
19
 
20
20
  system "mkdir -p #{backup_path}" unless Dir.exist?(backup_path)
21
21
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostgresHelper
4
- def config
5
- @config ||=
4
+ def configuration
5
+ @configuration ||=
6
6
  {
7
7
  database: Rails.configuration.database_configuration[Rails.env]['database'],
8
8
  username: Rails.configuration.database_configuration[Rails.env]['username'],
@@ -19,10 +19,10 @@ module PostgresHelper
19
19
  ENV['DEFAULT_URL'] || "#{Rails.env} Backup"
20
20
  end
21
21
 
22
- def content(result, config = {})
23
- @database = config[:database]
24
- @backup_path = config[:backup_path]
25
- @filename = config[:filename]
22
+ def content(result, settings = {})
23
+ @database = settings[:database]
24
+ @backup_path = settings[:backup_path]
25
+ @filename = settings[:filename]
26
26
 
27
27
  messages = []
28
28
  if result
@@ -34,13 +34,13 @@ module PostgresHelper
34
34
  messages.join("\n")
35
35
  end
36
36
 
37
- def dump_cmd(config = {})
38
- @hostname = config[:hostname]
39
- @database = config[:database]
40
- @username = config[:username]
41
- @password = config[:password]
42
- @portnumber = config[:portnumber]
43
- @backup_path = config[:backup_path]
37
+ def dump_cmd(settings = {})
38
+ @hostname = settings[:hostname]
39
+ @database = settings[:database]
40
+ @username = settings[:username]
41
+ @password = settings[:password]
42
+ @portnumber = settings[:portnumber]
43
+ @backup_path = settings[:backup_path]
44
44
 
45
45
  @date = Time.now.to_i
46
46
  options = []
@@ -17,11 +17,11 @@ namespace :storage do
17
17
  date = Time.now.to_i
18
18
  @filename = "storage_#{date}.tar.gz"
19
19
  FileUtils.mkdir_p(@backup_path) unless Dir.exist?(@backup_path)
20
- result = system "tar -zcf #{@backup_path}/#{@filename} -C #{@storage_path} ."
21
- FileUtils.rm_rf("#{@backup_path}/#{filename}") unless result
22
- puts result ? "Backup created: #{@backup_path}/#{@filename} (#{size_str(File.size("#{@backup_path}/#{@filename}"))})" : 'Backup failed removing dump file'
20
+ response = system "tar -zcf #{@backup_path}/#{@filename} -C #{@storage_path} ."
21
+ FileUtils.rm_rf("#{@backup_path}/#{filename}") unless response
22
+ puts response ? "Backup created: #{@backup_path}/#{@filename} (#{size_str(File.size("#{@backup_path}/#{@filename}"))})" : 'Backup failed removing dump file'
23
23
 
24
- if ENV['BACKUP_PROVIDER'].present? && external_backup && result
24
+ if ENV['BACKUP_PROVIDER'].present? && external_backup && response
25
25
  puts "Uploading #{@filename} to #{ENV['BACKUP_PROVIDER']}..."
26
26
  provider = Backup::Api.new
27
27
  begin
@@ -31,14 +31,14 @@ namespace :storage do
31
31
  puts "#{@filename} upload failed: #{e.message}"
32
32
  end
33
33
  end
34
- notification.send_backup_notification(result, title, message(result), { date: date, backup_path: @backup_path, database: 'storage' })
34
+ notification.send_backup_notification(response, title, message(response), { date: date, backup_path: @backup_path, database: 'storage' })
35
35
  end
36
36
 
37
37
  def title
38
38
  ENV['DEFAULT_URL'] || "#{Rails.env} Backup"
39
39
  end
40
40
 
41
- def message(result)
41
+ def message(result=false)
42
42
  messages = []
43
43
  if result
44
44
  messages << "Backup of storage folder successfully finished at #{Time.now}"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capistrano
4
4
  module Ops
5
- VERSION = '0.2.5'
5
+ VERSION = '0.2.6'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Crusius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-14 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3