scalingo_backups_manager 0.6.2 → 0.7.0

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: bec014dcdbd0fe4aa8a6e646b131b43f7af832aa3a13d22f24900d9dcfeff857
4
- data.tar.gz: 1758ce4b459fe4448ddeaeda52302e94b48083685148d398061bc4be96211574
3
+ metadata.gz: 9eecdc10b8f73d2a91d42fc47b3c53656f6089d0b3272fc6c40bb05b4239ed42
4
+ data.tar.gz: 97a79403c485891560862c3e3f9181a5e9df0c30f7fa6eb190303ee21137f466
5
5
  SHA512:
6
- metadata.gz: 7b7a1f1f853aa11ea8135effcc15df970aedf269145cccb471a430705f1130e71919116f93ed1f9b2c2062a141191f214d9c99bfe5bc5f3a806abf591453b3a0
7
- data.tar.gz: d313ddc959d7757050d9276e79a516395e119dc32de69278736d350a31a0ac1581a1c41b1b490ba1b842801710ba93e4985dd469312a7a0e5c88448b2494fe98
6
+ metadata.gz: 0b476dc2a1651226d6ef0c11961ce4815d5250c76657167c4081e5bc25091282f176be3406c9c7c7fdf237ba3483fe4f73430a47e9323020697e43a7c8625fc8
7
+ data.tar.gz: 339c818aecf115a985df7ae57bce015880abe5b4527a80f17ff8dbedb4cef2f7650720cf48423bf2c1fbdd0cfc8a31a25fe28a7928684d9426f898485a29b88b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scalingo_backups_manager (0.6.0)
4
+ scalingo_backups_manager (0.6.6)
5
5
  httparty (~> 0.18)
6
6
  net-sftp (~> 3.0.0)
7
7
  scalingo (~> 3.0)
@@ -10,27 +10,48 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (6.1.3.2)
13
+ activesupport (6.1.4.6)
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
18
  zeitwerk (~> 2.3)
19
- concurrent-ruby (1.1.8)
19
+ concurrent-ruby (1.1.9)
20
20
  diff-lcs (1.4.4)
21
- faraday (1.0.1)
21
+ faraday (1.10.0)
22
+ faraday-em_http (~> 1.0)
23
+ faraday-em_synchrony (~> 1.0)
24
+ faraday-excon (~> 1.1)
25
+ faraday-httpclient (~> 1.0)
26
+ faraday-multipart (~> 1.0)
27
+ faraday-net_http (~> 1.0)
28
+ faraday-net_http_persistent (~> 1.0)
29
+ faraday-patron (~> 1.0)
30
+ faraday-rack (~> 1.0)
31
+ faraday-retry (~> 1.0)
32
+ ruby2_keywords (>= 0.0.4)
33
+ faraday-em_http (1.0.0)
34
+ faraday-em_synchrony (1.0.0)
35
+ faraday-excon (1.1.0)
36
+ faraday-httpclient (1.0.1)
37
+ faraday-multipart (1.0.3)
22
38
  multipart-post (>= 1.2, < 3)
23
- faraday_middleware (1.0.0)
39
+ faraday-net_http (1.0.1)
40
+ faraday-net_http_persistent (1.2.0)
41
+ faraday-patron (1.0.0)
42
+ faraday-rack (1.0.0)
43
+ faraday-retry (1.0.3)
44
+ faraday_middleware (1.2.0)
24
45
  faraday (~> 1.0)
25
- httparty (0.18.1)
46
+ httparty (0.20.0)
26
47
  mime-types (~> 3.0)
27
48
  multi_xml (>= 0.5.2)
28
- i18n (1.8.10)
49
+ i18n (1.10.0)
29
50
  concurrent-ruby (~> 1.0)
30
- mime-types (3.3.1)
51
+ mime-types (3.4.1)
31
52
  mime-types-data (~> 3.2015)
32
- mime-types-data (3.2021.0225)
33
- minitest (5.14.4)
53
+ mime-types-data (3.2022.0105)
54
+ minitest (5.15.0)
34
55
  multi_json (1.15.0)
35
56
  multi_xml (0.6.0)
36
57
  multipart-post (2.1.1)
@@ -51,15 +72,16 @@ GEM
51
72
  diff-lcs (>= 1.2.0, < 2.0)
52
73
  rspec-support (~> 3.10.0)
53
74
  rspec-support (3.10.2)
54
- scalingo (3.0.0)
55
- activesupport (>= 5, < 7)
56
- faraday (~> 1.0.1)
57
- faraday_middleware (~> 1.0.0)
75
+ ruby2_keywords (0.0.5)
76
+ scalingo (3.1.0)
77
+ activesupport (>= 5, < 8)
78
+ faraday (~> 1.0)
79
+ faraday_middleware (~> 1.0)
58
80
  multi_json (~> 1.0, >= 1.0.3)
59
- thor (1.1.0)
81
+ thor (1.2.1)
60
82
  tzinfo (2.0.4)
61
83
  concurrent-ruby (~> 1.0)
62
- zeitwerk (2.4.2)
84
+ zeitwerk (2.5.4)
63
85
 
64
86
  PLATFORMS
65
87
  ruby
@@ -70,4 +92,4 @@ DEPENDENCIES
70
92
  scalingo_backups_manager!
71
93
 
72
94
  BUNDLED WITH
73
- 2.1.4
95
+ 2.2.28
@@ -89,7 +89,7 @@ module ScalingoBackupsManager
89
89
  if File.exist?(path)
90
90
  puts "Backup already download, skipping..."
91
91
  else
92
- system "curl #{download_link} -o #{path} --create-dirs"
92
+ system "curl #{download_link} -o #{path} --create-dirs -k"
93
93
  end
94
94
  else
95
95
  puts "No download link found for #{addon.addon_provider[:id]}, Skipping..."
@@ -164,6 +164,7 @@ module ScalingoBackupsManager
164
164
  when "daily"
165
165
  sftp.upload_file(path, remote_path, options: opts)
166
166
  files = sftp.list_files(remote_path)
167
+ p files.length
167
168
  puts "#{step} - Checking daily backups"
168
169
  step += 1
169
170
  if files.size > retention_config[:ttl]
@@ -63,7 +63,7 @@ module ScalingoBackupsManager
63
63
  puts "*** Restoring backup to mysql database ***"
64
64
  puts "Command: #{restore_cmd}"
65
65
  system(restore_cmd)
66
- #FileUtils.rm_r destination_path unless opts[:skip_rm]
66
+ FileUtils.rm_r destination_path unless opts[:skip_rm]
67
67
  end
68
68
 
69
69
  end
@@ -33,22 +33,32 @@ module ScalingoBackupsManager
33
33
  password: rails_db_config["password"],
34
34
  user: rails_db_config["user"],
35
35
  }
36
+ restore_cmd = ""
37
+ if config[:password].present?
38
+ restore_cmd = "PGPASSWORD=#{config[:password]} "
39
+ end
40
+ restore_cmd << "/usr/bin/env"
41
+ restore_cmd << " pg_restore"
36
42
 
37
- restore_cmd = "/usr/bin/env psql #{config[:database]} -h #{opts[:host] || config[:host]}"
43
+ file_path = Dir["#{destination_path}*.pgsql"]
44
+ if file_path.empty?
45
+ puts "*** No SQL file found in tar ***"
46
+ return
47
+ end
48
+ restore_cmd << " #{file_path.first}"
38
49
 
50
+ if config[:host].present?
51
+ restore_cmd << " -h #{opts[:host] || config[:host] || 'localhost'}"
52
+ end
39
53
  if config[:user].present?
40
- restore_cmd << " --u #{config[:user]}"
41
- if config[:password].present?
42
- restore_cmd << " --password"
43
- restore_cmd << " #{config[:password]}"
44
- end
54
+ restore_cmd << " -U #{config[:user]}"
45
55
  end
46
56
 
47
- if opts[:port].present? && config[:port].present?
57
+ if opts[:port].present? || config[:port].present?
48
58
  restore_cmd << " -p #{opts[:port] || config[:port] || 5432}"
49
59
  end
50
60
 
51
- restore_cmd << " < #{destination_path}"
61
+ restore_cmd << " -d #{config[:database]} --no-owner"
52
62
 
53
63
  puts "*** Restoring backup to Postgres database ***"
54
64
  system(restore_cmd)
@@ -10,16 +10,25 @@ module ScalingoBackupsManager
10
10
  end
11
11
 
12
12
  def start
13
- Net::SFTP.start(@ftp_host[:host], @ftp_host[:user], password: @ftp_host[:password], port: @ftp_host[:port]) do |sftp|
14
- yield(sftp) if block_given?
13
+ if @ftp_host[:password]
14
+ Net::SFTP.start(@ftp_host[:host], @ftp_host[:user], password: @ftp_host[:password], port: @ftp_host[:port]) do |sftp|
15
+ yield(sftp) if block_given?
16
+ end
17
+ elsif @ftp_host[:private_key_path]
18
+ Net::SFTP.start(@ftp_host[:host], @ftp_host[:user], key_data: [], keys: @ftp_host[:private_key_path], keys_only: true, port: @ftp_host[:port]) do |sftp|
19
+ yield(sftp) if block_given?
20
+ end
15
21
  end
16
22
  end
17
23
 
18
24
  def list_files(path)
19
25
  files = []
20
26
  start do |sftp|
21
- sftp.dir.glob("#{path}", "*.tar.gz").each do |file|
22
- files << file
27
+ begin
28
+ sftp.dir.glob("#{path}", "*.tar.gz").each do |file|
29
+ files << file
30
+ end
31
+ rescue
23
32
  end
24
33
  end
25
34
  files
@@ -36,7 +45,6 @@ module ScalingoBackupsManager
36
45
  folder_tree = []
37
46
  path.split("/").each do |folder_name|
38
47
  next if folder_name.blank?
39
-
40
48
  folder_tree << folder_name
41
49
  begin
42
50
  sftp.mkdir!(folder_tree.join("/"))
@@ -1,3 +1,3 @@
1
1
  module ScalingoBackupsManager
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.0"
3
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.6.2
4
+ version: 0.7.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: 2021-06-02 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.0.3
124
+ rubygems_version: 3.1.6
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Gem allowing to download backups from scalingo