scalingo_backups_manager 0.8.0 → 0.9.0

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: 22aae190ac267f91679c59c01c34a385d7d31b8859c05c106e280bd8c449bc32
4
- data.tar.gz: 4db5340d871f30d632067a274178837561716c289fe57fa72b1cc7a7af6a38cc
3
+ metadata.gz: de3bae8aee21115bc798c52df63e0ddc785e11ab10b2420a762848d1896d50ef
4
+ data.tar.gz: a1284ed86a12de0029d40d6cc540fd5e2a2e69e64fc598f8ab6bafd64a3d1fc8
5
5
  SHA512:
6
- metadata.gz: 50c9ee867cfbb4f09c14cc82a7675ebd43c561d87fdaea720cf4ad0455be6aec87dcb022103e82638bc722c2c09f07fe29386c621e05338e30cafd43074eb8a2
7
- data.tar.gz: af4e44b07ad73739b00fdb2e77be8c7dd80e8a0fdff376e87cfaf73c3a1e2618e90761adc46c5d61477b78c1730f2c0c3fadf705b2ed8cb5822008230b559bf6
6
+ metadata.gz: c58e1ed24cd527487d858bd341ed14e5480431b95245bd062e8adc38beb7130fc9d726fa6a818ae2e879cac83212d2470778b072ce11d3f71edf76b697f922a4
7
+ data.tar.gz: 00775f8db0dea7792cf701aea40727852f6d6b0e5fe3ec6cfbfea3976eb9f7ade0fe305b0fae6619ba4fb1c86cf99ff4f59a41e73200428397d2e388c9c6bf88
@@ -3,6 +3,13 @@ module ScalingoBackupsManager
3
3
 
4
4
  class Notification
5
5
 
6
+ def self.send_healthchecks_notification(hook_url, message)
7
+ HTTParty.get(
8
+ hook_url,
9
+ headers: { 'Content-Type' => 'application/json' }
10
+ )
11
+ end
12
+
6
13
  def self.send_slack_notification(hook_url, message)
7
14
  HTTParty.post(
8
15
  hook_url,
@@ -17,7 +17,6 @@ module ScalingoBackupsManager
17
17
  destination_path = filename.split("/")
18
18
  backup_name = destination_path.pop.gsub(".tar.gz", "")
19
19
  destination_path = destination_path.join("/") + backup_name + "/"
20
- p destination_path
21
20
  if Dir.exist?(destination_path)
22
21
  puts "Unzipped backup is already present, skipping..."
23
22
  else
@@ -26,12 +25,13 @@ module ScalingoBackupsManager
26
25
  system untar_cmd
27
26
  end
28
27
 
29
- rails_db_config = YAML.load(ERB.new(File.read("config/#{opts[:database_config_file]}")).result)[opts[:env]]
28
+ rails_db_config = YAML.load(ERB.new(File.read("config/#{opts[:database_config_file]}")).result)[opts[:env].to_s]
30
29
  config = {
31
30
  host: rails_db_config["host"],
32
31
  database: rails_db_config["database"],
33
32
  password: rails_db_config["password"],
34
33
  user: rails_db_config["user"],
34
+ port: rails_db_config["port"]
35
35
  }
36
36
  restore_cmd = ""
37
37
  if config[:password].present?
@@ -61,6 +61,7 @@ module ScalingoBackupsManager
61
61
  restore_cmd << " -d #{config[:database]} --no-owner"
62
62
 
63
63
  puts "*** Restoring backup to Postgres database ***"
64
+ puts restore_cmd
64
65
  system(restore_cmd)
65
66
  FileUtils.rm_r destination_path unless opts[:skip_rm]
66
67
  end
@@ -60,6 +60,9 @@ module ScalingoBackupsManager
60
60
  begin
61
61
  sftp.upload!(filepath, "#{remote_dir}/#{filename}")
62
62
  rescue
63
+ if options.dig(:webhooks, :healthchecks_webhook_url)
64
+ ScalingoBackupsManager::Notification.send_healthchecks_notification(options.dig(:webhooks, :healthchecks_webhook_url), "An error has occured while uploading backup, see the logs for more information")
65
+ end
63
66
  if options.dig(:webhooks, :slack_webhook_url)
64
67
  ScalingoBackupsManager::Notification.send_slack_notification(options.dig(:webhooks, :slack_webhook_url), "An error has occured while uploading backup, see the logs for more information")
65
68
  end
@@ -1,3 +1,3 @@
1
1
  module ScalingoBackupsManager
2
- VERSION = "0.8.0"
3
- end
2
+ VERSION = "0.9.0"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scalingo_backups_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Clercin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor