capistrano-ops 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano/ops/backup/s3.rb +3 -3
- data/lib/capistrano/ops/capistrano/v3/tasks/backup/backup_helper.rb +1 -1
- data/lib/capistrano/ops/capistrano/v3/tasks/backup.rake +1 -1
- data/lib/capistrano/ops/tasks/pg/dump.rake +4 -4
- data/lib/capistrano/ops/tasks/pg/postgres_helper.rb +13 -13
- data/lib/capistrano/ops/tasks/storage/backup.rake +6 -6
- data/lib/capistrano/ops/version.rb +1 -1
- 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: 2e6ea5cb2553a8bedbdff2a067fc0eebc9084fad7da2034dc27ca544de536b84
|
4
|
+
data.tar.gz: bd22e1378dd96b52b06de1d5c1c048400e4a382878a97bf0d9d2441a6a2e02b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b350bf93e1e2fe881486e7693a832aedfaff2e75e3ae271fe08f3f70ee6f3ebbfce7fd871eb44a4627f832d92b8855846c7b6045165b31607358a35923467c11
|
7
|
+
data.tar.gz: 0fc695db5edb67785a0ce5533bfe5d23a64dd596a6c87d4aededc76f44bfb6e858cc4fb1af59dab5b6bd4e635e8b3fc4b67eaa4d4d8a0fa43ced32229757a843
|
@@ -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)
|
@@ -12,7 +12,7 @@ module BackupHelper
|
|
12
12
|
|
13
13
|
def download_backup(backup_file, type)
|
14
14
|
puts "Downloading #{type} backup"
|
15
|
-
download! "#{shared_path}/backups/#{backup_file}"
|
15
|
+
download! "#{shared_path}/backups/#{backup_file}" , backup_file
|
16
16
|
puts "Download finished\nDeleting temporary backup..."
|
17
17
|
cleanup_backup(backup_file, "Download finished\nDeleting temporary backup...")
|
18
18
|
end
|
@@ -19,7 +19,7 @@ namespace :backup do
|
|
19
19
|
on roles(rake_roles) do
|
20
20
|
warn "deprecated: use 'backup:database:pull' instead, in future versions this task will be removed"
|
21
21
|
backup_file = backup_file_name('database')
|
22
|
-
download! "#{shared_path}/backups/#{backup_file}"
|
22
|
+
download! "#{shared_path}/backups/#{backup_file}", backup_file
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -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.7
|
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-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|