capistrano-ops 0.2.5 → 0.2.7

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
  SHA256:
3
- metadata.gz: 9ff5391932b65811de3330a802d309df6d78dc1d2b6b04cc60b5c86dfe0de6e1
4
- data.tar.gz: 769c58ef06c175441bc53a673ee379394fc343cfdfe37612999b204508db742d
3
+ metadata.gz: 2e6ea5cb2553a8bedbdff2a067fc0eebc9084fad7da2034dc27ca544de536b84
4
+ data.tar.gz: bd22e1378dd96b52b06de1d5c1c048400e4a382878a97bf0d9d2441a6a2e02b6
5
5
  SHA512:
6
- metadata.gz: e2e68e6ebb4da63511fe2a8712eeee07368b3ab6f427faa0be00799784ba73aa67eb49787d6c09f67a6da9dd6dda08e0c57296e3b1f621505e5db40576aaab1a
7
- data.tar.gz: 0752765d093c875d5d96eb7b32451dc38a2f15519920f1bf85ebb1c6c926e4161e7e9488f681ee0d2067ca22b0192efab994e3ae268a55521b8789b7bc077b93
6
+ metadata.gz: b350bf93e1e2fe881486e7693a832aedfaff2e75e3ae271fe08f3f70ee6f3ebbfce7fd871eb44a4627f832d92b8855846c7b6045165b31607358a35923467c11
7
+ data.tar.gz: 0fc695db5edb67785a0ce5533bfe5d23a64dd596a6c87d4aededc76f44bfb6e858cc4fb1af59dab5b6bd4e635e8b3fc4b67eaa4d4d8a0fa43ced32229757a843
@@ -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)
@@ -12,7 +12,7 @@ module BackupHelper
12
12
 
13
13
  def download_backup(backup_file, type)
14
14
  puts "Downloading #{type} backup"
15
- download! "#{shared_path}/backups/#{backup_file}"
15
+ download! "#{shared_path}/backups/#{backup_file}" , backup_file
16
16
  puts "Download finished\nDeleting temporary backup..."
17
17
  cleanup_backup(backup_file, "Download finished\nDeleting temporary backup...")
18
18
  end
@@ -19,7 +19,7 @@ namespace :backup do
19
19
  on roles(rake_roles) do
20
20
  warn "deprecated: use 'backup:database:pull' instead, in future versions this task will be removed"
21
21
  backup_file = backup_file_name('database')
22
- download! "#{shared_path}/backups/#{backup_file}"
22
+ download! "#{shared_path}/backups/#{backup_file}", backup_file
23
23
  end
24
24
  end
25
25
  end
@@ -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.7'
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.7
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-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3