bard-backup 0.3.0 → 0.3.2
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 +4 -4
- data/README.md +1 -1
- data/lib/bard/backup/s3_dir.rb +5 -3
- data/lib/bard/backup/version.rb +1 -1
- data/lib/bard/backup.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ecd12f3233d3f91b3d2683931ae3b99251a85773da44ddad9607a584654592
|
4
|
+
data.tar.gz: a2e1febf07c7e630be1b32d17f78eea4c31e298bd1c60defe983c39449e26a5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db8add94f2212367e0de47f8097ec8f4cf2bf7515049862e9e78450f062af6c25078f3c3bb62cb34f306b1d52343b777046a51176b802afb2d5fc3eed881549a
|
7
|
+
data.tar.gz: a1305345c4a9516758bba2c169d68d07b2d95ad420e8b54b9e914d4bfb1320231dad9ceccc6a4855bdb2476ed7b77ccb1dc0b0b23aab3142d20da5a191bcd9af
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Bard::Backup does 3 things in a bard project
|
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
|
12
|
-
Run with `Bard::Backup.call s3_path, access_key: "...", secret_key: "..."`
|
12
|
+
Run with `Bard::Backup.call s3_path, access_key: "...", secret_key: "...", region: "..."`
|
13
13
|
|
14
14
|
Or just run via the `bard-rake` gem: `rake db:backup`, which wires up the above for you.
|
15
15
|
|
data/lib/bard/backup/s3_dir.rb
CHANGED
@@ -3,7 +3,7 @@ require "rexml"
|
|
3
3
|
|
4
4
|
module Bard
|
5
5
|
module Backup
|
6
|
-
class S3Dir < Data.define(:path, :access_key, :secret_key)
|
6
|
+
class S3Dir < Data.define(:path, :access_key, :secret_key, :region)
|
7
7
|
def keys
|
8
8
|
response = client.list_objects_v2({
|
9
9
|
bucket: bucket_name,
|
@@ -16,12 +16,13 @@ module Bard
|
|
16
16
|
def put file_path, body: File.read(file_path)
|
17
17
|
client.put_object({
|
18
18
|
bucket: bucket_name,
|
19
|
-
key:
|
19
|
+
key: [folder_prefix, File.basename(file_path)].compact.join("/"),
|
20
20
|
body: body,
|
21
21
|
})
|
22
22
|
end
|
23
23
|
|
24
24
|
def delete keys
|
25
|
+
return if keys.empty?
|
25
26
|
objects_to_delete = Array(keys).map { |key| { key: key } }
|
26
27
|
client.delete_objects({
|
27
28
|
bucket: bucket_name,
|
@@ -43,6 +44,7 @@ module Bard
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def folder_prefix
|
47
|
+
return nil if !path.include?("/")
|
46
48
|
path.split("/")[1..].join("/")
|
47
49
|
end
|
48
50
|
|
@@ -50,7 +52,7 @@ module Bard
|
|
50
52
|
|
51
53
|
def client
|
52
54
|
Aws::S3::Client.new({
|
53
|
-
region:
|
55
|
+
region: region,
|
54
56
|
access_key_id: access_key,
|
55
57
|
secret_access_key: secret_key,
|
56
58
|
})
|
data/lib/bard/backup/version.rb
CHANGED
data/lib/bard/backup.rb
CHANGED
@@ -5,9 +5,9 @@ require "backhoe"
|
|
5
5
|
|
6
6
|
module Bard
|
7
7
|
module Backup
|
8
|
-
def self.call s3_path, access_key:, secret_key:, now: Time.now.utc
|
8
|
+
def self.call s3_path, access_key:, secret_key:, region: "us-west-2", now: Time.now.utc
|
9
9
|
dumper = Backhoe
|
10
|
-
s3_dir = S3Dir.new(path: s3_path, access_key:, secret_key:)
|
10
|
+
s3_dir = S3Dir.new(path: s3_path, access_key:, secret_key:, region:)
|
11
11
|
Controller.new(dumper, s3_dir, now).call
|
12
12
|
Deleter.new(s3_dir, now).call
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backhoe
|