scalingo_backups_manager 0.8.0 → 0.9.2

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: 22aae190ac267f91679c59c01c34a385d7d31b8859c05c106e280bd8c449bc32
4
- data.tar.gz: 4db5340d871f30d632067a274178837561716c289fe57fa72b1cc7a7af6a38cc
3
+ metadata.gz: 0db4f23f57c4f65c48b84afd49649ffca17d4e191c9958d717d61ea47daef770
4
+ data.tar.gz: fd07f83715c99a5c8686dcc9046ed1ac596865302fcd7b1511a574761e085319
5
5
  SHA512:
6
- metadata.gz: 50c9ee867cfbb4f09c14cc82a7675ebd43c561d87fdaea720cf4ad0455be6aec87dcb022103e82638bc722c2c09f07fe29386c621e05338e30cafd43074eb8a2
7
- data.tar.gz: af4e44b07ad73739b00fdb2e77be8c7dd80e8a0fdff376e87cfaf73c3a1e2618e90761adc46c5d61477b78c1730f2c0c3fadf705b2ed8cb5822008230b559bf6
6
+ metadata.gz: 6fd91f8fee5dfdc32577d12f04e59bf9e8a433410080e061ecec918718bd781cc05ce6239c8f661187a83fd5eefd6aa81f406c1b53ef39248b23ecddd573c4d8
7
+ data.tar.gz: 1c2267b5ba17516168b88a368ca1a42899eb1a27a0cc34d39f57612a2f7fd01987a6e0a77fbc8cb5535af67e16e4fe18bfd1d5eea4a72b8e2503668ede996cc5
@@ -0,0 +1,36 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build + Publish
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ packages: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Ruby 2.6
20
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
21
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
22
+ # uses: ruby/setup-ruby@v1
23
+ uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
24
+ with:
25
+ ruby-version: 3.1.1
26
+
27
+ - name: Publish to RubyGems
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem build *.gemspec
34
+ gem push *.gem
35
+ env:
36
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scalingo_backups_manager (0.7.0)
4
+ scalingo_backups_manager (0.9.2)
5
5
  httparty (~> 0.18)
6
6
  net-sftp (~> 3.0.0)
7
7
  scalingo (~> 3.0)
@@ -90,4 +90,4 @@ DEPENDENCIES
90
90
  scalingo_backups_manager!
91
91
 
92
92
  BUNDLED WITH
93
- 2.3.13
93
+ 2.4.17
@@ -24,6 +24,7 @@ module ScalingoBackupsManager
24
24
 
25
25
  def database_api_url(options: {})
26
26
  return @database_api_url if @database_api_url
27
+
27
28
  @database_api_url = "#{options[:database_api_root_url] || DEFAULT_DATABASE_API_ROOT_URL}/api/databases/#{id}"
28
29
  end
29
30
 
@@ -40,7 +41,7 @@ module ScalingoBackupsManager
40
41
 
41
42
  addon_cli_config = Scalingo::Client.new
42
43
  addon_cli_config.token = bearer_token
43
- @client = Scalingo::API::Client.new(database_api_url(options), scalingo: addon_cli_config)
44
+ @client = Scalingo::API::Client.new(database_api_url(options: options), scalingo: addon_cli_config)
44
45
  end
45
46
 
46
47
 
@@ -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,
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'fileutils'
2
3
  require 'erb'
3
4
  module ScalingoBackupsManager
4
5
  module Restore
@@ -29,12 +30,15 @@ module ScalingoBackupsManager
29
30
  system untar_cmd
30
31
  end
31
32
 
32
- rails_db_config = YAML.load(ERB.new(File.read("config/#{opts[:database_config_file]}")).result)[opts[:env]]
33
+ database_yml_content = File.read("config/#{opts[:database_config_file]}")
34
+ parsed_database_config = ERB.new(database_yml_content).result
35
+ rails_db_config = YAML.load(parsed_database_config)[opts[:env]]
33
36
  config = {
34
37
  host: rails_db_config["host"],
35
38
  database: rails_db_config["database"],
36
39
  password: rails_db_config["password"],
37
40
  user: rails_db_config["username"],
41
+ port: rails_db_config["port"]
38
42
  }
39
43
 
40
44
  restore_cmd = "/usr/bin/env mysql -h #{opts[:host] || config[:host]}"
@@ -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
@@ -25,13 +24,13 @@ module ScalingoBackupsManager
25
24
  untar_cmd = "tar zxvf #{filename} -C #{destination_path}"
26
25
  system untar_cmd
27
26
  end
28
-
29
- rails_db_config = YAML.load(ERB.new(File.read("config/#{opts[:database_config_file]}")).result)[opts[:env]]
27
+ rails_db_config = YAML.load(ERB.new(File.read("config/#{opts[:database_config_file]}")).result)[opts[:env].to_s]
30
28
  config = {
31
29
  host: rails_db_config["host"],
32
30
  database: rails_db_config["database"],
33
31
  password: rails_db_config["password"],
34
32
  user: rails_db_config["user"],
33
+ port: rails_db_config["port"]
35
34
  }
36
35
  restore_cmd = ""
37
36
  if config[:password].present?
@@ -61,6 +60,7 @@ module ScalingoBackupsManager
61
60
  restore_cmd << " -d #{config[:database]} --no-owner"
62
61
 
63
62
  puts "*** Restoring backup to Postgres database ***"
63
+ puts restore_cmd
64
64
  system(restore_cmd)
65
65
  FileUtils.rm_r destination_path unless opts[:skip_rm]
66
66
  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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Clercin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2024-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.0.0
69
- description:
69
+ description:
70
70
  email:
71
71
  - kevin@9troisquarts.com
72
72
  executables:
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".DS_Store"
78
+ - ".github/workflows/gem-push.yml"
78
79
  - ".gitignore"
79
80
  - ".rspec"
80
81
  - ".travis.yml"
@@ -107,7 +108,7 @@ metadata:
107
108
  homepage_uri: https://github.com/9troisquarts/scalingo_backups_manager
108
109
  source_code_uri: https://github.com/9troisquarts/scalingo_backups_manager
109
110
  changelog_uri: https://github.com/9troisquarts/scalingo_backups_manager/CHANGELOG.md
110
- post_install_message:
111
+ post_install_message:
111
112
  rdoc_options: []
112
113
  require_paths:
113
114
  - lib
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubygems_version: 3.3.7
126
- signing_key:
127
+ signing_key:
127
128
  specification_version: 4
128
129
  summary: Gem allowing to download backups from scalingo
129
130
  test_files: []