backy_rb 0.1.6 → 0.1.7

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: 5869c45131402a06e9bd79a71e3cc82a3a0e867006fa9fa9b9f46bb7f1bd60b8
4
- data.tar.gz: 614e88a654a7fd62d4426f8bbe1966ac3727229dbfe3d38dd5b171ae76e0bd9f
3
+ metadata.gz: 00ab5005d9a22cf24c18c8fb7a9a5fa0a202eb1a19ee137cca3d51f41999bfc6
4
+ data.tar.gz: 1a9e412072b4d6f57e9c1d32362eddcbecd5f700ae8f612d4c67a5604be3e176
5
5
  SHA512:
6
- metadata.gz: c731f5764a173ba08cae49dc3abf6b4212b4b9b5f66757849b88b9be49511c13cd92fe8d64fb65e468992108b32ac877e1c2049afb5d390d8529f29092e746c4
7
- data.tar.gz: 6e068f09ffaecbe95b9857cd947584a86ba3c0b18b70698cb709b91aa0711706de950121d47dbd03af91d0d3e610d790c2317296e742fcdf7e56456721f76abe
6
+ metadata.gz: 5440e8a4dbd149b823ebe27115277a5fafd96cdafec5f4a6269bb7d8832b02cf206feac6f673cef89e84d325b97c0fc75e9698e0e002c5eed974dada5fcbdb16
7
+ data.tar.gz: 6f9534e4a3a33e1281a85d926bd6b4b1a348ea95061ba22828b2b24d4a8404bd831c51d6cb5e3766a094f66b7dad2f6d4cfd45019f638e2731cb3308dad7f169
data/CHANGELOG.md CHANGED
@@ -1,8 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to `Backy` will be documented in this file.
4
+
1
5
  ## [Unreleased]
2
6
 
3
- ## [0.1.4] - 2023-12-28
4
- - Adds CLI
7
+ ## [0.1.7] - 2024-06-21
8
+ ### Added
9
+ - Support for setting database params via PG_URL
10
+ - Make S3 bucket prefix configurable
11
+
12
+ ## [0.1.6] - 2023-12-28
13
+ ### Added
14
+ - Support for parallel pg_dump processes.
15
+ - Support for parallel pg_restore processes.
16
+ - Added CLI
5
17
 
6
- ## [0.1.0] - 2023-03-30
18
+ ### Changed
19
+ - Improved performance of the backup process.
20
+ - Rename gem from `backy` to `backy_rb`.
7
21
 
8
- - Initial release
22
+ ## [0.1.3] - 2023-06-23
23
+ - Initial release of `Backy`.
24
+ - Support for AWS S3 integration.
25
+ - Rails application auto-configuration feature.
@@ -10,6 +10,7 @@ module Backy
10
10
  :s3_access_key,
11
11
  :s3_secret,
12
12
  :s3_bucket,
13
+ :s3_prefix,
13
14
  :app_name,
14
15
  :environment,
15
16
  :use_parallel,
@@ -25,6 +26,20 @@ module Backy
25
26
  load_from_file(config_file) if File.exist?(config_file)
26
27
  end
27
28
 
29
+ def pg_url=(url)
30
+ @pg_url = url
31
+ pg_config = parse_postgres_uri(url)
32
+ @pg_host = pg_config[:host]
33
+ @pg_port = pg_config[:port]
34
+ @pg_username = pg_config[:username]
35
+ @pg_password = pg_config[:password]
36
+ @pg_database = pg_config[:database_name]
37
+ end
38
+
39
+ def pg_url
40
+ @pg_url ||= ENV["PG_URL"]
41
+ end
42
+
28
43
  def pg_host
29
44
  @pg_host ||= ENV["PG_HOST"]
30
45
  end
@@ -61,6 +76,10 @@ module Backy
61
76
  @s3_bucket ||= ENV["S3_BUCKET"]
62
77
  end
63
78
 
79
+ def s3_prefix
80
+ @s3_prefix ||= ENV["S3_PREFIX"].presence || "/db/dump/"
81
+ end
82
+
64
83
  def use_parallel
65
84
  @use_parallel ||= ENV["BACKY_USE_PARALLEL"] == "true"
66
85
  end
@@ -113,17 +132,36 @@ module Backy
113
132
  @s3_secret = configuration.dig("defaults", "s3", "secret_access_key")
114
133
  @s3_region = configuration.dig("defaults", "s3", "region")
115
134
  @s3_bucket = configuration.dig("defaults", "s3", "bucket")
135
+ @s3_prefix = configuration.dig("defaults", "s3", "prefix") || s3_prefix
116
136
 
117
- @pg_host = configuration.dig("defaults", "database", "host")
118
- @pg_port = configuration.dig("defaults", "database", "port")
119
- @pg_username = configuration.dig("defaults", "database", "username")
120
- @pg_password = configuration.dig("defaults", "database", "password")
121
- @pg_database = configuration.dig("defaults", "database", "database_name")
137
+ @pg_url = configuration.dig("defaults", "database", "pg_url")
138
+ if @pg_url
139
+ self.pg_url = @pg_url
140
+ else
141
+ @pg_host = configuration.dig("defaults", "database", "host")
142
+ @pg_port = configuration.dig("defaults", "database", "port")
143
+ @pg_username = configuration.dig("defaults", "database", "username")
144
+ @pg_password = configuration.dig("defaults", "database", "password")
145
+ @pg_database = configuration.dig("defaults", "database", "database_name")
146
+ end
122
147
 
123
148
  @app_name = configuration.dig("defaults", "app_name") || "backy"
124
149
  @environment = configuration.dig("defaults", "environment") || "development"
125
150
  @log_file = configuration.dig("defaults", "log", "file") || default_log_file
126
151
  @use_parallel = configuration.dig("defaults", "use_parallel") || false
127
152
  end
153
+
154
+ def parse_postgres_uri(uri)
155
+ parsed_uri = URI.parse(uri)
156
+
157
+ {
158
+ adapter: "postgresql",
159
+ host: parsed_uri.host,
160
+ port: parsed_uri.port,
161
+ username: parsed_uri.user,
162
+ password: parsed_uri.password,
163
+ database_name: parsed_uri.path[1..]
164
+ }
165
+ end
128
166
  end
129
167
  end
data/lib/backy/s3.rb CHANGED
@@ -11,6 +11,7 @@ module Backy
11
11
  def_delegator "Backy.configuration", :s3_secret, :secret
12
12
  def_delegator "Backy.configuration", :s3_bucket, :bucket
13
13
  def_delegator "Backy.configuration", :s3_access_key, :access_key
14
+ def_delegator "Backy.configuration", :s3_prefix, :prefix
14
15
 
15
16
  def s3
16
17
  @s3 ||= Aws::S3::Client.new(region: region, credentials: s3_credentials)
data/lib/backy/s3_list.rb CHANGED
@@ -2,12 +2,6 @@ module Backy
2
2
  class S3List
3
3
  include S3
4
4
 
5
- DEFAULT_PREFIX = "db/dump/"
6
-
7
- def initialize(prefix: nil)
8
- @prefix = prefix || DEFAULT_PREFIX
9
- end
10
-
11
5
  def call
12
6
  return [] unless s3_configured?
13
7
 
@@ -23,9 +17,5 @@ module Backy
23
17
 
24
18
  result.sort
25
19
  end
26
-
27
- private
28
-
29
- attr_reader :prefix
30
20
  end
31
21
  end
data/lib/backy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Backy
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backy_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Kharchenko
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-12-28 00:00:00.000000000 Z
13
+ date: 2024-06-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
274
  requirements: []
275
- rubygems_version: 3.4.22
275
+ rubygems_version: 3.5.5
276
276
  signing_key:
277
277
  specification_version: 4
278
278
  summary: Backy is a powerful and user-friendly database backup gem designed specifically