nxt_heroku_database_backup 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f97418f01f18ca7de20dcc6f67d8598d6d8e21725c58d6f8c689918089d449
|
4
|
+
data.tar.gz: 6adfded58467cdcb883c805c3e95d584acc4d6433d55fd4df86bb82fe44253d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa2557b59d6ca4ec1aa5a8c3d2c722037f4c816ce678ac2b3809cfd3a80e1786664eb9434fe97bf30897544816a50957ddf10c9b30cb867eddfc71d62e626bd8
|
7
|
+
data.tar.gz: 83b30af454d3f11a1b6ce2ff39513d0a71c1b26b02b1b813108fe8f2e41f705e9213d1d32b1b7a963ce6425cadd60a4fad253a315352696a0150be1973b2edee
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ module NxtHerokuDatabaseBackup
|
|
12
12
|
environment: -> { default_environment },
|
13
13
|
backup_name: -> { default_backup_name },
|
14
14
|
backup_tmp_path: -> { default_backup_tmp_path },
|
15
|
-
uploader: -> { Uploader::S3.
|
15
|
+
uploader: -> { Uploader::S3.build(bucket_name: upload_destination, file_path: encrypted_backup_tmp_path) }
|
16
16
|
|
17
17
|
|
18
18
|
def backup_latest_dump
|
@@ -3,7 +3,17 @@ module NxtHerokuDatabaseBackup
|
|
3
3
|
class S3
|
4
4
|
include NxtInit
|
5
5
|
|
6
|
-
attr_init :bucket_name, :file_path
|
6
|
+
attr_init :bucket_name, :file_path, :credentials
|
7
|
+
|
8
|
+
def self.build(bucket_name:, file_path:, credentials: nil)
|
9
|
+
credentials ||= {
|
10
|
+
access_key_id: ENV.fetch('DATABASE_BACKUP_AWS_ACCESS_KEY_ID'),
|
11
|
+
secret_access_key: ENV.fetch('DATABASE_BACKUP_AWS_SECRET_ACCESS_KEY'),
|
12
|
+
region: ENV.fetch('DATABASE_BACKUP_AWS_REGION')
|
13
|
+
}
|
14
|
+
|
15
|
+
new(bucket_name: bucket_name, file_path: file_path, credentials: credentials)
|
16
|
+
end
|
7
17
|
|
8
18
|
def call
|
9
19
|
aws_object.upload_file(file_path)
|
@@ -22,20 +32,8 @@ module NxtHerokuDatabaseBackup
|
|
22
32
|
client.create_bucket(bucket: bucket_name)
|
23
33
|
end
|
24
34
|
|
25
|
-
def bucket_name
|
26
|
-
@bucket_name ||= "#{heroku_app_name}-db-backups"
|
27
|
-
end
|
28
|
-
|
29
35
|
def client
|
30
|
-
@client ||= Aws::S3::Client.new(**
|
31
|
-
end
|
32
|
-
|
33
|
-
def aws_credentials
|
34
|
-
{
|
35
|
-
access_key_id: ENV.fetch('DATABASE_BACKUP_AWS_ACCESS_KEY_ID'),
|
36
|
-
secret_access_key: ENV.fetch('DATABASE_BACKUP_AWS_SECRET_ACCESS_KEY'),
|
37
|
-
region: ENV.fetch('DATABASE_BACKUP_AWS_REGION')
|
38
|
-
}
|
36
|
+
@client ||= Aws::S3::Client.new(**credentials)
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|