capistrano-ops 0.2.5 → 0.2.6
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: 1ddab185886973237cac8aab6671b9bb580d5496f72e37f0678b6b0dd794c78a
|
4
|
+
data.tar.gz: 4c12ffe04071978d364f6a02b5d0cfd3a0e651a8669b86c00e2445c1830bc74b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36dc0e5814ab7ff1b7370b366cf8dce0f8c4092f300319c7d2f936c554455ad7bd1edb5e519c80157515f0590d55ca4f995f9dbbadcd72d7803040e7c4ffb5bd
|
7
|
+
data.tar.gz: e2a9c85b8a361cca26a84bdade6500d31f8ab63e3f792e002dd7db5b3949779eb9fbfe5fccad7496fc4baff6baa7dbb3c6921e933ca7dd11a3f3ba61ca83bec0
|
@@ -11,13 +11,13 @@ module Backup
|
|
11
11
|
self.region = region
|
12
12
|
self.access_key_id = access_key_id
|
13
13
|
self.secret_access_key = secret_access_key
|
14
|
-
|
14
|
+
configuration = {
|
15
15
|
region: region,
|
16
16
|
access_key_id: access_key_id,
|
17
17
|
secret_access_key: secret_access_key
|
18
18
|
}
|
19
|
-
|
20
|
-
self.s3_resource = Aws::S3::Resource.new(
|
19
|
+
configuration[:endpoint] = endpoint unless endpoint.nil?
|
20
|
+
self.s3_resource = Aws::S3::Resource.new(configuration)
|
21
21
|
end
|
22
22
|
|
23
23
|
def upload(backup_file, key)
|
@@ -5,9 +5,9 @@ namespace :pg do
|
|
5
5
|
include PostgresHelper
|
6
6
|
|
7
7
|
task :dump do
|
8
|
-
backup_path =
|
9
|
-
backups_enabled =
|
10
|
-
external_backup =
|
8
|
+
backup_path = configuration[:backup_path]
|
9
|
+
backups_enabled = configuration[:backups_enabled]
|
10
|
+
external_backup = configuration[:external_backup]
|
11
11
|
|
12
12
|
unless backups_enabled
|
13
13
|
puts 'dump: Backups are disabled'
|
@@ -15,7 +15,7 @@ namespace :pg do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
notification = Notification::Api.new
|
18
|
-
commandlist = dump_cmd(
|
18
|
+
commandlist = dump_cmd(configuration)
|
19
19
|
|
20
20
|
system "mkdir -p #{backup_path}" unless Dir.exist?(backup_path)
|
21
21
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module PostgresHelper
|
4
|
-
def
|
5
|
-
@
|
4
|
+
def configuration
|
5
|
+
@configuration ||=
|
6
6
|
{
|
7
7
|
database: Rails.configuration.database_configuration[Rails.env]['database'],
|
8
8
|
username: Rails.configuration.database_configuration[Rails.env]['username'],
|
@@ -19,10 +19,10 @@ module PostgresHelper
|
|
19
19
|
ENV['DEFAULT_URL'] || "#{Rails.env} Backup"
|
20
20
|
end
|
21
21
|
|
22
|
-
def content(result,
|
23
|
-
@database =
|
24
|
-
@backup_path =
|
25
|
-
@filename =
|
22
|
+
def content(result, settings = {})
|
23
|
+
@database = settings[:database]
|
24
|
+
@backup_path = settings[:backup_path]
|
25
|
+
@filename = settings[:filename]
|
26
26
|
|
27
27
|
messages = []
|
28
28
|
if result
|
@@ -34,13 +34,13 @@ module PostgresHelper
|
|
34
34
|
messages.join("\n")
|
35
35
|
end
|
36
36
|
|
37
|
-
def dump_cmd(
|
38
|
-
@hostname =
|
39
|
-
@database =
|
40
|
-
@username =
|
41
|
-
@password =
|
42
|
-
@portnumber =
|
43
|
-
@backup_path =
|
37
|
+
def dump_cmd(settings = {})
|
38
|
+
@hostname = settings[:hostname]
|
39
|
+
@database = settings[:database]
|
40
|
+
@username = settings[:username]
|
41
|
+
@password = settings[:password]
|
42
|
+
@portnumber = settings[:portnumber]
|
43
|
+
@backup_path = settings[:backup_path]
|
44
44
|
|
45
45
|
@date = Time.now.to_i
|
46
46
|
options = []
|
@@ -17,11 +17,11 @@ namespace :storage do
|
|
17
17
|
date = Time.now.to_i
|
18
18
|
@filename = "storage_#{date}.tar.gz"
|
19
19
|
FileUtils.mkdir_p(@backup_path) unless Dir.exist?(@backup_path)
|
20
|
-
|
21
|
-
FileUtils.rm_rf("#{@backup_path}/#{filename}") unless
|
22
|
-
puts
|
20
|
+
response = system "tar -zcf #{@backup_path}/#{@filename} -C #{@storage_path} ."
|
21
|
+
FileUtils.rm_rf("#{@backup_path}/#{filename}") unless response
|
22
|
+
puts response ? "Backup created: #{@backup_path}/#{@filename} (#{size_str(File.size("#{@backup_path}/#{@filename}"))})" : 'Backup failed removing dump file'
|
23
23
|
|
24
|
-
if ENV['BACKUP_PROVIDER'].present? && external_backup &&
|
24
|
+
if ENV['BACKUP_PROVIDER'].present? && external_backup && response
|
25
25
|
puts "Uploading #{@filename} to #{ENV['BACKUP_PROVIDER']}..."
|
26
26
|
provider = Backup::Api.new
|
27
27
|
begin
|
@@ -31,14 +31,14 @@ namespace :storage do
|
|
31
31
|
puts "#{@filename} upload failed: #{e.message}"
|
32
32
|
end
|
33
33
|
end
|
34
|
-
notification.send_backup_notification(
|
34
|
+
notification.send_backup_notification(response, title, message(response), { date: date, backup_path: @backup_path, database: 'storage' })
|
35
35
|
end
|
36
36
|
|
37
37
|
def title
|
38
38
|
ENV['DEFAULT_URL'] || "#{Rails.env} Backup"
|
39
39
|
end
|
40
40
|
|
41
|
-
def message(result)
|
41
|
+
def message(result=false)
|
42
42
|
messages = []
|
43
43
|
if result
|
44
44
|
messages << "Backup of storage folder successfully finished at #{Time.now}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Crusius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|