backup 4.2.0 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/backup/notifier/hipchat.rb +11 -1
- data/lib/backup/notifier/mail.rb +17 -2
- data/lib/backup/package.rb +4 -0
- data/lib/backup/storage/base.rb +15 -3
- data/lib/backup/storage/cycler.rb +24 -14
- data/lib/backup/storage/ftp.rb +15 -1
- data/lib/backup/version.rb +1 -1
- data/templates/cli/notifiers/hipchat +1 -0
- data/templates/cli/notifiers/mail +3 -0
- data/templates/cli/storages/dropbox +1 -0
- data/templates/cli/storages/ftp +1 -0
- data/templates/cli/storages/local +1 -0
- data/templates/cli/storages/ninefold +1 -0
- data/templates/cli/storages/s3 +2 -0
- data/templates/cli/storages/scp +1 -0
- data/templates/cli/storages/sftp +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d08d993d32d7569046700f059019d19276be8d4f
|
4
|
+
data.tar.gz: a0f8b82c36a16137008774c5107c03f2cb560488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd3300ce800e95d11097dcf02c79965917d9aac7bb58a89e482248a6f3a37084efce66885cfd6b2f8892611b17dd2381df3fdb78c3e052da34e9eb8882b215e
|
7
|
+
data.tar.gz: dec002458b652dde7ea835c4366581252d1bd1961fca6e125c3677abedf72c03ca90313fa78ca0d8dfc2449575f3542cf399eb98bbdcd8873971f71d57a8fb6c
|
@@ -9,6 +9,11 @@ module Backup
|
|
9
9
|
# The Hipchat API token
|
10
10
|
attr_accessor :token
|
11
11
|
|
12
|
+
##
|
13
|
+
# The Hipchat API version
|
14
|
+
# Either 'v1' or 'v2' (default is 'v1')
|
15
|
+
attr_accessor :api_version
|
16
|
+
|
12
17
|
##
|
13
18
|
# Who the notification should appear from
|
14
19
|
attr_accessor :from
|
@@ -45,6 +50,7 @@ module Backup
|
|
45
50
|
@success_color ||= 'yellow'
|
46
51
|
@warning_color ||= 'yellow'
|
47
52
|
@failure_color ||= 'yellow'
|
53
|
+
@api_version ||= 'v1'
|
48
54
|
end
|
49
55
|
|
50
56
|
private
|
@@ -72,9 +78,13 @@ module Backup
|
|
72
78
|
send_message(msg, status_data[:color])
|
73
79
|
end
|
74
80
|
|
81
|
+
def client_options
|
82
|
+
{ api_version: @api_version }
|
83
|
+
end
|
84
|
+
|
75
85
|
# Hipchat::Client will raise an error if unsuccessful.
|
76
86
|
def send_message(msg, color)
|
77
|
-
client = HipChat::Client.new(token)
|
87
|
+
client = HipChat::Client.new(token, client_options)
|
78
88
|
rooms_to_notify.each do |room|
|
79
89
|
client[room].send(from, msg, :color => color, :notify => notify_users)
|
80
90
|
end
|
data/lib/backup/notifier/mail.rb
CHANGED
@@ -37,6 +37,18 @@ module Backup
|
|
37
37
|
# Receiver Email Address
|
38
38
|
attr_accessor :to
|
39
39
|
|
40
|
+
##
|
41
|
+
# CC receiver Email Address
|
42
|
+
attr_accessor :cc
|
43
|
+
|
44
|
+
##
|
45
|
+
# BCC receiver Email Address
|
46
|
+
attr_accessor :bcc
|
47
|
+
|
48
|
+
##
|
49
|
+
# Set reply to email address
|
50
|
+
attr_accessor :reply_to
|
51
|
+
|
40
52
|
##
|
41
53
|
# SMTP Server Address
|
42
54
|
attr_accessor :address
|
@@ -208,8 +220,11 @@ module Backup
|
|
208
220
|
end
|
209
221
|
|
210
222
|
email = ::Mail.new
|
211
|
-
email.to
|
212
|
-
email.from
|
223
|
+
email.to = to
|
224
|
+
email.from = from
|
225
|
+
email.cc = cc
|
226
|
+
email.bcc = bcc
|
227
|
+
email.reply_to = reply_to
|
213
228
|
email
|
214
229
|
end
|
215
230
|
|
data/lib/backup/package.rb
CHANGED
data/lib/backup/storage/base.rb
CHANGED
@@ -10,8 +10,18 @@ module Backup
|
|
10
10
|
attr_accessor :path
|
11
11
|
|
12
12
|
##
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# Number of backups to keep or time until which to keep.
|
14
|
+
#
|
15
|
+
# If an Integer is given it sets the limit to how many backups to keep in
|
16
|
+
# the remote location. If exceeded, the oldest will be removed to make
|
17
|
+
# room for the newest.
|
18
|
+
#
|
19
|
+
# If a Time object is given it will remove backups _older_ than the given
|
20
|
+
# date.
|
21
|
+
#
|
22
|
+
# @!attribute [rw] keep
|
23
|
+
# @param [Integer|Time]
|
24
|
+
# @return [Integer|Time]
|
15
25
|
attr_accessor :keep
|
16
26
|
|
17
27
|
attr_reader :model, :package, :storage_id
|
@@ -33,7 +43,9 @@ module Backup
|
|
33
43
|
def perform!
|
34
44
|
Logger.info "#{ storage_name } Started..."
|
35
45
|
transfer!
|
36
|
-
|
46
|
+
if respond_to?(:cycle!, true) && (keep.to_i > 0 || keep.is_a?(Time))
|
47
|
+
cycle!
|
48
|
+
end
|
37
49
|
Logger.info "#{ storage_name } Finished!"
|
38
50
|
end
|
39
51
|
|
@@ -14,24 +14,34 @@ module Backup
|
|
14
14
|
Logger.info 'Cycling Started...'
|
15
15
|
|
16
16
|
packages = yaml_load.unshift(package)
|
17
|
-
|
17
|
+
cycled_packages = []
|
18
18
|
|
19
|
-
if
|
20
|
-
packages.
|
21
|
-
|
22
|
-
remove!(pkg) unless pkg.no_cycle
|
23
|
-
rescue => err
|
24
|
-
Logger.warn Error.wrap(err, <<-EOS)
|
25
|
-
There was a problem removing the following package:
|
26
|
-
Trigger: #{pkg.trigger} :: Dated: #{pkg.time}
|
27
|
-
Package included the following #{ pkg.filenames.count } file(s):
|
28
|
-
#{ pkg.filenames.join("\n") }
|
29
|
-
EOS
|
30
|
-
end
|
19
|
+
if keep.is_a?(Date) || keep.is_a?(Time)
|
20
|
+
cycled_packages = packages.select do |p|
|
21
|
+
p.time_as_object < keep.to_time
|
31
22
|
end
|
23
|
+
else
|
24
|
+
excess = packages.count - keep.to_i
|
25
|
+
cycled_packages = packages.last(excess) if excess > 0
|
32
26
|
end
|
33
27
|
|
34
|
-
|
28
|
+
saved_packages = packages - cycled_packages
|
29
|
+
cycled_packages.each { |package| delete_package package }
|
30
|
+
|
31
|
+
yaml_save(saved_packages)
|
32
|
+
end
|
33
|
+
|
34
|
+
def delete_package(package)
|
35
|
+
begin
|
36
|
+
remove!(package) unless package.no_cycle
|
37
|
+
rescue => err
|
38
|
+
Logger.warn Error.wrap(err, <<-EOS)
|
39
|
+
There was a problem removing the following package:
|
40
|
+
Trigger: #{package.trigger} :: Dated: #{package.time}
|
41
|
+
Package included the following #{ package.filenames.count } file(s):
|
42
|
+
#{ package.filenames.join("\n") }
|
43
|
+
EOS
|
44
|
+
end
|
35
45
|
end
|
36
46
|
|
37
47
|
# Returns path to the YAML data file.
|
data/lib/backup/storage/ftp.rb
CHANGED
@@ -15,15 +15,25 @@ module Backup
|
|
15
15
|
attr_accessor :ip, :port
|
16
16
|
|
17
17
|
##
|
18
|
-
#
|
18
|
+
# Use passive mode?
|
19
19
|
attr_accessor :passive_mode
|
20
20
|
|
21
|
+
##
|
22
|
+
# Configure connection open and read timeouts.
|
23
|
+
# Net::FTP's open_timeout and read_timeout will both be configured using
|
24
|
+
# this setting.
|
25
|
+
# @!attribute [rw] timeout
|
26
|
+
# @param [Integer|Float]
|
27
|
+
# @return [Integer|Float]
|
28
|
+
attr_accessor :timeout
|
29
|
+
|
21
30
|
def initialize(model, storage_id = nil)
|
22
31
|
super
|
23
32
|
|
24
33
|
@port ||= 21
|
25
34
|
@path ||= 'backups'
|
26
35
|
@passive_mode ||= false
|
36
|
+
@timeout ||= nil
|
27
37
|
path.sub!(/^~\//, '')
|
28
38
|
end
|
29
39
|
|
@@ -42,6 +52,10 @@ module Backup
|
|
42
52
|
end; Net::FTP.send(:const_set, :FTP_PORT, port)
|
43
53
|
|
44
54
|
Net::FTP.open(ip, username, password) do |ftp|
|
55
|
+
if timeout
|
56
|
+
ftp.open_timeout = timeout
|
57
|
+
ftp.read_timeout = timeout
|
58
|
+
end
|
45
59
|
ftp.passive = true if passive_mode
|
46
60
|
yield ftp
|
47
61
|
end
|
data/lib/backup/version.rb
CHANGED
data/templates/cli/storages/ftp
CHANGED
data/templates/cli/storages/s3
CHANGED
data/templates/cli/storages/scp
CHANGED
data/templates/cli/storages/sftp
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael van Rooijen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: CFPropertyList
|