gat 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
data/History.txt
CHANGED
data/lib/gat/version.rb
CHANGED
@@ -41,8 +41,6 @@ class GatgetDarBackup < Gat::Base
|
|
41
41
|
|
42
42
|
backups_path = get_dependence_value("folders", "backups_folder_data_local")
|
43
43
|
last_complet_backup = SystemBackup.find(:last, backups_path, { :current => true, :type => 'complet'})
|
44
|
-
|
45
|
-
|
46
44
|
if not last_complet_backup
|
47
45
|
|
48
46
|
# * perform a complet backup
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class SystemBackup
|
2
|
-
|
2
|
+
|
3
3
|
attr_accessor :name
|
4
4
|
attr_accessor :isolate
|
5
5
|
attr_accessor :isolate_slices
|
@@ -11,7 +11,7 @@ class SystemBackup
|
|
11
11
|
attr_accessor :folder
|
12
12
|
attr_accessor :current
|
13
13
|
attr_accessor :full_dar_path
|
14
|
-
|
14
|
+
|
15
15
|
def initialize(backup_file, backup_folder_path, current_folder)
|
16
16
|
@name = backup_file.split('.').first
|
17
17
|
@isolate = has_isolate?("#{ backup_folder_path }/#{ @name }")
|
@@ -24,72 +24,70 @@ class SystemBackup
|
|
24
24
|
@type = @name.include?('complet') ? 'complet' : 'diff'
|
25
25
|
@folder = backup_folder_path.split('/').last
|
26
26
|
@current = @folder == current_folder
|
27
|
-
|
27
|
+
|
28
28
|
@full_dar_path = "#{ backup_folder_path }/#{ @name }"
|
29
|
-
|
29
|
+
|
30
30
|
end
|
31
|
-
|
32
|
-
|
31
|
+
|
32
|
+
|
33
33
|
def self.find(how_many, path_to_search, conditions = {})
|
34
|
-
|
34
|
+
|
35
35
|
current_folder = nil
|
36
36
|
if File.exists?("#{ path_to_search }/current")
|
37
37
|
current_folder = File.readlink("#{ path_to_search }/current").gsub(/\//,'')
|
38
38
|
end
|
39
|
-
|
40
39
|
all_backups = get_backups_in(path_to_search, current_folder)
|
41
40
|
backups = []
|
42
|
-
|
41
|
+
|
43
42
|
all_backups.each do |backup|
|
44
43
|
backups << backup if SystemBackup.valid_backup_file?(backup, conditions)
|
45
44
|
end
|
46
|
-
|
47
45
|
if how_many == :first
|
48
46
|
return_backups = backups.first
|
49
|
-
elsif how_many == :last
|
47
|
+
elsif how_many == :last
|
50
48
|
return_backups = backups.last
|
51
49
|
elsif how_many == :all
|
52
50
|
return_backups = backups
|
53
51
|
else
|
54
52
|
raise Gat::GatgetProcessException.new("Undefined return backups symbol #{ how_many }", "find")
|
55
53
|
end
|
56
|
-
|
54
|
+
|
57
55
|
return_backups
|
58
56
|
end
|
59
|
-
|
60
|
-
|
57
|
+
|
58
|
+
|
61
59
|
def search_pattern(pattern)
|
62
60
|
unless self.has_dump?(self.full_dar_path)
|
63
61
|
raise Gat::GatgetProcessException.new("Unable to search_pattern withour dump. Create it first", "search_pattern")
|
64
62
|
end
|
65
|
-
|
63
|
+
|
66
64
|
results = ''
|
67
|
-
|
65
|
+
|
68
66
|
dump_file = File.open("#{ self.full_dar_path }_dump", "r")
|
69
|
-
|
67
|
+
|
70
68
|
dump_file.each_line do |line|
|
71
69
|
if line.include?(pattern)
|
72
70
|
results << line
|
73
71
|
end
|
74
72
|
end
|
75
|
-
|
73
|
+
|
76
74
|
results
|
77
75
|
end
|
78
|
-
|
76
|
+
|
79
77
|
protected
|
80
78
|
def has_isolate?(path)
|
81
79
|
File.exists?("#{ path }_isolate.1.dar")
|
82
80
|
end
|
83
|
-
|
81
|
+
|
84
82
|
def has_dump?(path)
|
85
83
|
File.exists?("#{ path }_dump")
|
86
84
|
end
|
87
|
-
|
85
|
+
|
88
86
|
private
|
89
87
|
def self.valid_backup_file?(backup, conditions)
|
90
|
-
|
88
|
+
|
91
89
|
valid_conditions = [ :current, :dump, :isolate, :folder, :type]
|
92
|
-
|
90
|
+
|
93
91
|
conditions.each_key do |cond|
|
94
92
|
unless valid_conditions.include?(cond)
|
95
93
|
raise Gat::GatgetProcessException.new("Find backup with condition #{ cond }. Condition not valid", "valid_backup_file?")
|
@@ -102,19 +100,18 @@ class SystemBackup
|
|
102
100
|
passed = false
|
103
101
|
end
|
104
102
|
end
|
105
|
-
|
103
|
+
|
106
104
|
passed
|
107
105
|
end
|
108
|
-
|
106
|
+
|
109
107
|
def self.get_backups_in(path_to_search, current_folder)
|
110
|
-
|
111
108
|
backups = []
|
112
109
|
(Dir.entries(path_to_search) - ['current', '.', '..']).each do |backup_folder|
|
113
|
-
|
110
|
+
puts backup_folder
|
114
111
|
backup_folder_path = "#{ path_to_search }/#{ backup_folder }"
|
115
|
-
|
112
|
+
|
116
113
|
(Dir.entries(backup_folder_path) - ['..', '.' ]).each do |backup_file|
|
117
|
-
|
114
|
+
puts backup_file
|
118
115
|
if SystemBackup.is_reference_backup_file?(backup_file)
|
119
116
|
backups << SystemBackup.new(backup_file, backup_folder_path, current_folder)
|
120
117
|
end
|
@@ -122,13 +119,13 @@ class SystemBackup
|
|
122
119
|
end
|
123
120
|
backups
|
124
121
|
end
|
125
|
-
|
122
|
+
|
126
123
|
# reference file is the first slice of backup. No isolate, no dump
|
127
124
|
def self.is_reference_backup_file?(name)
|
128
125
|
name.include?('.1.dar') and not name.include?('_isolate') and not name.include?('_dump')
|
129
126
|
end
|
130
|
-
|
131
|
-
|
127
|
+
|
128
|
+
|
132
129
|
def slices_for(path, name)
|
133
130
|
slices = []
|
134
131
|
(Dir.entries(path) - ['.', '..']).each do |entry|
|
@@ -138,6 +135,6 @@ class SystemBackup
|
|
138
135
|
end
|
139
136
|
slices
|
140
137
|
end
|
141
|
-
|
142
|
-
|
138
|
+
|
139
|
+
|
143
140
|
end
|
@@ -63,6 +63,33 @@ class GatgetSynchronization < Gat::Base
|
|
63
63
|
end
|
64
64
|
|
65
65
|
|
66
|
+
def notify_end
|
67
|
+
st_notify_email_ended = get_dependence_value("static", "notify_email_ended")
|
68
|
+
if st_notify_email_ended && st_notify_email_ended["sent_to"]
|
69
|
+
to = st_notify_email_ended
|
70
|
+
end
|
71
|
+
subject = st_notify_email_ended["subject"]
|
72
|
+
body = st_notify_email_ended["body"]
|
73
|
+
if to.nil?
|
74
|
+
if self.config["email_config"]
|
75
|
+
to = self.config["email_config"]["send_to"]
|
76
|
+
else
|
77
|
+
raise Gat::GatgetConfigException.new("Default email config[to] is empty at gatget.config['email_config']", "run_output_email")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
subject = "Rsync ended" if subject.nil?
|
81
|
+
body = "Define your own body in static.notify_email_ended.body" if body.nil?
|
82
|
+
|
83
|
+
full_subject = "[GAT] [#{ self.class.name }] [#{ self.operation.name.camelize }] #{subject}"
|
84
|
+
create_and_deliver_email(to,
|
85
|
+
{ 'subject' => full_subject,
|
86
|
+
'body' => body },
|
87
|
+
self.config["email_config"]
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
66
93
|
# send rescue email will send a email for notification errors at do_backup operation
|
67
94
|
def onfail
|
68
95
|
|
@@ -11,6 +11,11 @@ static:
|
|
11
11
|
notify_email_started:
|
12
12
|
subject: Rsync started
|
13
13
|
body: You will receive an email when the rsync is ended
|
14
|
+
to: sandraantolin@lopez-brea.com
|
15
|
+
notify_email_ended:
|
16
|
+
subject: Rsync finished
|
17
|
+
body: Rsync finished OK
|
18
|
+
to: sandraantolin@lopez-brea.com
|
14
19
|
my_host_remote_folder: /home/backup/
|
15
20
|
my_host_remote_host: my_host
|
16
21
|
my_host_remote_user: backup
|
@@ -84,8 +89,8 @@ operations:
|
|
84
89
|
folders: [ source, dest ]
|
85
90
|
helpers: [ ]
|
86
91
|
conditions: [ check_enough_space_for_sync ]
|
87
|
-
actions: [ notify_start, exec_local_rsync ]
|
88
|
-
outputs: [
|
92
|
+
actions: [ notify_start, exec_local_rsync, notify_end ]
|
93
|
+
outputs: [ ]
|
89
94
|
onfail: [ ]
|
90
95
|
options:
|
91
96
|
verbose: 1
|
@@ -125,6 +130,8 @@ operations:
|
|
125
130
|
actions:
|
126
131
|
notify_start:
|
127
132
|
type: ruby_method
|
133
|
+
notify_end:
|
134
|
+
type: ruby_method
|
128
135
|
exec_local_rsync:
|
129
136
|
type: shell_command
|
130
137
|
syntax: "rsync -az --delete {{folders_source}} {{folders_dest}}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gnoxys
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-23 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|