scalingo_backups_manager 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +2 -1
- data/Gemfile.lock +5 -7
- data/lib/scalingo_backups_manager/cli.rb +15 -11
- data/lib/scalingo_backups_manager/notification.rb +7 -0
- data/lib/scalingo_backups_manager/restore/postgres.rb +3 -2
- data/lib/scalingo_backups_manager/sftp_tools.rb +3 -0
- data/lib/scalingo_backups_manager/version.rb +2 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3bae8aee21115bc798c52df63e0ddc785e11ab10b2420a762848d1896d50ef
|
4
|
+
data.tar.gz: a1284ed86a12de0029d40d6cc540fd5e2a2e69e64fc598f8ab6bafd64a3d1fc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58e1ed24cd527487d858bd341ed14e5480431b95245bd062e8adc38beb7130fc9d726fa6a818ae2e879cac83212d2470778b072ce11d3f71edf76b697f922a4
|
7
|
+
data.tar.gz: 00775f8db0dea7792cf701aea40727852f6d6b0e5fe3ec6cfbfea3976eb9f7ade0fe305b0fae6619ba4fb1c86cf99ff4f59a41e73200428397d2e388c9c6bf88
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
scalingo_backups_manager (0.
|
4
|
+
scalingo_backups_manager (0.7.0)
|
5
5
|
httparty (~> 0.18)
|
6
6
|
net-sftp (~> 3.0.0)
|
7
7
|
scalingo (~> 3.0)
|
@@ -10,13 +10,12 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (
|
13
|
+
activesupport (7.0.3)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 1.6, < 2)
|
16
16
|
minitest (>= 5.1)
|
17
17
|
tzinfo (~> 2.0)
|
18
|
-
|
19
|
-
concurrent-ruby (1.1.9)
|
18
|
+
concurrent-ruby (1.1.10)
|
20
19
|
diff-lcs (1.4.4)
|
21
20
|
faraday (1.10.0)
|
22
21
|
faraday-em_http (~> 1.0)
|
@@ -54,7 +53,7 @@ GEM
|
|
54
53
|
minitest (5.15.0)
|
55
54
|
multi_json (1.15.0)
|
56
55
|
multi_xml (0.6.0)
|
57
|
-
multipart-post (2.
|
56
|
+
multipart-post (2.2.0)
|
58
57
|
net-sftp (3.0.0)
|
59
58
|
net-ssh (>= 5.0.0, < 7.0.0)
|
60
59
|
net-ssh (6.1.0)
|
@@ -81,7 +80,6 @@ GEM
|
|
81
80
|
thor (1.2.1)
|
82
81
|
tzinfo (2.0.4)
|
83
82
|
concurrent-ruby (~> 1.0)
|
84
|
-
zeitwerk (2.5.4)
|
85
83
|
|
86
84
|
PLATFORMS
|
87
85
|
ruby
|
@@ -92,4 +90,4 @@ DEPENDENCIES
|
|
92
90
|
scalingo_backups_manager!
|
93
91
|
|
94
92
|
BUNDLED WITH
|
95
|
-
2.
|
93
|
+
2.3.13
|
@@ -79,20 +79,24 @@ module ScalingoBackupsManager
|
|
79
79
|
end
|
80
80
|
|
81
81
|
configuration.for_each_addons(searched_application, searched_addon) do |application, addon|
|
82
|
-
|
83
|
-
next unless backups.size > 0
|
84
|
-
backup = backups.first
|
85
|
-
download_link = backup.download_link
|
86
|
-
if download_link
|
82
|
+
begin
|
87
83
|
puts "Downloading #{application.name} last backup"
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
backups = addon.backups
|
85
|
+
next unless backups.size > 0
|
86
|
+
backup = backups.first
|
87
|
+
download_link = backup.download_link
|
88
|
+
if download_link
|
89
|
+
path = ("#{addon.config[:path]}" || "backups/#{addon.addon_provider[:id]}") + "/#{Time.now.strftime("%Y%m%d")}.tar.gz"
|
90
|
+
if File.exist?(path)
|
91
|
+
puts "Backup already download, skipping..."
|
92
|
+
else
|
93
|
+
system "curl #{download_link} -o #{path} --create-dirs -k"
|
94
|
+
end
|
91
95
|
else
|
92
|
-
|
96
|
+
puts "No download link found for #{addon.addon_provider[:id]}, Skipping..."
|
93
97
|
end
|
94
|
-
|
95
|
-
puts "
|
98
|
+
rescue
|
99
|
+
puts "Issue with configuration of #{application.name}"
|
96
100
|
end
|
97
101
|
end
|
98
102
|
end
|
@@ -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.
|
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.
|
4
|
+
version: 0.9.0
|
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:
|
11
|
+
date: 2023-02-23 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:
|
@@ -74,6 +74,7 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- ".DS_Store"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".travis.yml"
|
@@ -106,7 +107,7 @@ metadata:
|
|
106
107
|
homepage_uri: https://github.com/9troisquarts/scalingo_backups_manager
|
107
108
|
source_code_uri: https://github.com/9troisquarts/scalingo_backups_manager
|
108
109
|
changelog_uri: https://github.com/9troisquarts/scalingo_backups_manager/CHANGELOG.md
|
109
|
-
post_install_message:
|
110
|
+
post_install_message:
|
110
111
|
rdoc_options: []
|
111
112
|
require_paths:
|
112
113
|
- lib
|
@@ -121,8 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
122
|
- !ruby/object:Gem::Version
|
122
123
|
version: '0'
|
123
124
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
125
|
-
signing_key:
|
125
|
+
rubygems_version: 3.3.7
|
126
|
+
signing_key:
|
126
127
|
specification_version: 4
|
127
128
|
summary: Gem allowing to download backups from scalingo
|
128
129
|
test_files: []
|