yore 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -15,12 +15,6 @@ and can use Amazon S3 for storage.
15
15
  * Compressed, encrypted, single file backups of folders and mysql databases
16
16
  * Can be called regularly eg. by cron
17
17
  * Backups can be uploaded to Amazon S3
18
- * will later remove old files that don't match the configurable scheme for backup history,
19
- but keeping a useful history eg.
20
- - backup every day
21
- - keep 2 weeks of daily backups
22
- - keep 12 weeks of friday backups
23
- - keep the first friday backup of each month forever
24
18
  * Can automatically collect and compress database all user data from particular applications
25
19
  to a single file, and restore to another server. Known applications are Rails-centric but others
26
20
  can be manually configured.
data/Rakefile CHANGED
@@ -12,9 +12,8 @@ begin
12
12
  gem.authors = ["buzzware"]
13
13
  gem.rubyforge_project = "buzzware"
14
14
  gem.add_dependency('cmdparse', '>= 2.0.2')
15
- gem.add_dependency('buzzcore', '>= 0.2.6')
15
+ gem.add_dependency('buzzcore', '>= 0.3.1')
16
16
  gem.add_dependency('nokogiri', '>= 1.3.3')
17
- gem.add_dependency('buzzcore', '>= 0.2.6')
18
17
  gem.add_dependency('aws-s3', '>= 0.6.2')
19
18
  gem.add_development_dependency "thoughtbot-shoulda"
20
19
  #gem.files.include %w(
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/bin/yore CHANGED
@@ -4,8 +4,6 @@ require 'fileutils'
4
4
 
5
5
  require 'rubygems'
6
6
 
7
- require File.expand_path('../../buzzcore/lib/buzzcore_dev',File.dirname(__FILE__))
8
-
9
7
  gem 'buzzcore'; require 'buzzcore';
10
8
  gem 'cmdparse'; require 'cmdparse'
11
9
 
@@ -13,64 +13,6 @@ THIS_DIR = File.dirname(THIS_FILE)
13
13
 
14
14
  module YoreCore
15
15
 
16
- class KeepDaily
17
-
18
- attr_reader :keep_age
19
-
20
- def initialize(aKeepAge=14)
21
- @keep_age = aKeepAge
22
- end
23
-
24
- def is?
25
- true
26
- end
27
-
28
- def age(aDate)
29
-
30
- end
31
- def keep?(aDate)
32
-
33
- end
34
- end
35
-
36
- class KeepWeekly
37
-
38
- attr_reader :keep_age
39
-
40
- def initialize(aKeepAge=14)
41
- @keep_age = aKeepAge
42
- end
43
-
44
- def is?
45
-
46
- end
47
- def age(aDate)
48
-
49
- end
50
- def keep?(aDate)
51
-
52
- end
53
- end
54
-
55
- class KeepMonthly
56
-
57
- attr_reader :keep_age
58
-
59
- def initialize(aKeepAge=14)
60
- @keep_age = aKeepAge
61
- end
62
-
63
- def is?
64
-
65
- end
66
- def age(aDate)
67
-
68
- end
69
- def keep?(aDate)
70
-
71
- end
72
- end
73
-
74
16
  class Yore
75
17
 
76
18
  DEFAULT_CONFIG = {
@@ -78,9 +20,6 @@ module YoreCore
78
20
  :basepath => String,
79
21
  :backup_id => String,
80
22
  :backup_email => String,
81
- :keep_daily => 14,
82
- :keep_weekly => 12,
83
- :keep_monthly => 12,
84
23
  :crypto_iv => "3A63775C1E3F291B0925578165EB917E", # apparently a string of up to 32 random hex digits
85
24
  :crypto_key => "07692FC8656F04AE5518B80D38681E038A3C12050DF6CC97CEEC33D800D5E2FE", # apparently a string of up to 64 random hex digits
86
25
  :first_hour => 4,
@@ -105,7 +44,6 @@ module YoreCore
105
44
  attr_reader :config
106
45
  attr_reader :logger
107
46
  attr_reader :reporter
108
- attr_reader :keepers
109
47
  attr_reader :s3client
110
48
 
111
49
  def initialize(aConfig=nil)
@@ -133,7 +71,7 @@ module YoreCore
133
71
  #aOptions may require {:basepath => File.dirname(File.expand_path(job))}
134
72
  def self.launch(aConfigXml,aCmdOptions=nil,aOptions=nil)
135
73
  if !aConfigXml
136
- path = MiscUtils.path_combine(aOptions && aOptions[:basepath],'yore.config.xml')
74
+ path = MiscUtils.canonize_path('yore.config.xml',aOptions && aOptions[:basepath])
137
75
  aConfigXml = path if File.exists?(path)
138
76
  end
139
77
  result = Yore.new()
@@ -163,46 +101,33 @@ module YoreCore
163
101
  return dbyml[aRailsEnv] && dbyml[aRailsEnv].symbolize_keys
164
102
  end
165
103
 
166
- def self.find_upwards(aStartPath,aPath)
167
- curr_path = File.expand_path(aStartPath)
168
- while curr_path && !(test_path_exists = File.exists?(test_path = File.join(curr_path,aPath))) do
169
- curr_path = MiscUtils.path_parent(curr_path)
170
- end
171
- curr_path && test_path_exists ? test_path : nil
172
- end
173
-
174
104
  def expand_app_option(kind=nil)
175
105
  kind = config[:kind] unless kind && !kind.empty?
176
106
  return nil unless kind && !kind.empty?
177
107
  config.xmlRoot = create_empty_config_xml() if !config.xmlRoot
108
+ xmlSources = XmlUtils.single_node(config.xmlRoot,'/Yore/Sources') || XmlUtils.add_xml_from_string('<Sources/>',XmlUtils.single_node(config.xmlRoot,'/Yore'))
178
109
  case kind
179
110
  when 'spree'
180
111
  # add file source
181
- xmlSources = XmlUtils.single_node(config.xmlRoot,'/Yore/Sources')
182
- if xmlSources
183
- strSource = <<-EOS
184
- <Source Type="File">
185
- <IncludePath BasePath="public/assets">products</IncludePath>
186
- </Source>
187
- EOS
188
- XmlUtils.add_xml_from_string(strSource,xmlSources)
189
- end
112
+ strSource = <<-EOS
113
+ <Source Type="File">
114
+ <IncludePath BasePath="public/assets">products</IncludePath>
115
+ </Source>
116
+ EOS
117
+ XmlUtils.add_xml_from_string(strSource,xmlSources)
190
118
  expand_app_option('rails') # do again
191
119
  #
192
120
  # if capistrano deployed, uploads are assumed to be in shared/uploads
193
121
  #
194
122
  when 'browsercms'
195
123
  # add file source
196
- xmlSources = XmlUtils.single_node(config.xmlRoot,'/Yore/Sources')
197
- if xmlSources
198
- uploadParent = File.join(config[:basepath],'tmp') unless config[:basepath]['/releases/'] && uploadParent = Yore.find_upwards(config[:basepath],'shared')
199
- strSource = <<-EOS
200
- <Source Type="File">
201
- <IncludePath BasePath="#{uploadParent}">uploads</IncludePath>
202
- </Source>
203
- EOS
204
- XmlUtils.add_xml_from_string(strSource,xmlSources)
205
- end
124
+ uploadParent = MiscUtils.expand_magic_path('.../shared',config[:basepath]) || File.join(config[:basepath],'tmp')
125
+ strSource = <<-EOS
126
+ <Source Type="File">
127
+ <IncludePath BasePath="#{uploadParent}">uploads</IncludePath>
128
+ </Source>
129
+ EOS
130
+ XmlUtils.add_xml_from_string(strSource,xmlSources)
206
131
  expand_app_option('rails') # do again
207
132
  when 'rails'
208
133
  # * add db source from database.yml
@@ -210,18 +135,16 @@ module YoreCore
210
135
  #if (dbyml = YAML::load(File.open(File.expand_path('config/database.yml',config[:basepath]))) rescue nil)
211
136
  # if env = (config[:RAILS_ENV] && config[:RAILS_ENV]!='' && config[:RAILS_ENV])
212
137
  # if (db_details = dbyml[env]) &&
213
- xmlSources = XmlUtils.single_node(config.xmlRoot,'/Yore/Sources')
214
- if xmlSources
215
- #<Database Name="#{db_details[:database]}" Host="#{db_details[:host]}" User="#{db_details[:username]}" Password="#{db_details[:password]}">
216
- strSource = <<-EOS
217
- <Source Type="MySql" >
218
- <Database Yml="config/database.yml">
219
- <ArchiveFile>rails_app.sql</ArchiveFile>
220
- </Database>
221
- </Source>
222
- EOS
223
- XmlUtils.add_xml_from_string(strSource,xmlSources)
224
- end
138
+
139
+ #<Database Name="#{db_details[:database]}" Host="#{db_details[:host]}" User="#{db_details[:username]}" Password="#{db_details[:password]}">
140
+ strSource = <<-EOS
141
+ <Source Type="MySql" >
142
+ <Database Yml="config/database.yml">
143
+ <ArchiveFile>rails_app.sql</ArchiveFile>
144
+ </Database>
145
+ </Source>
146
+ EOS
147
+ XmlUtils.add_xml_from_string(strSource,xmlSources)
225
148
  end
226
149
  end
227
150
 
@@ -230,7 +153,7 @@ module YoreCore
230
153
  def configure(aConfig,aCmdOptions = nil,aOptions = nil)
231
154
  config_to_read = {}
232
155
  if aConfig.is_a?(String)
233
- aConfig = File.expand_path(aConfig)
156
+ aConfig = MiscUtils.canonize_path(aConfig)
234
157
  logger.info "Job file: #{aConfig}"
235
158
  op = {:basepath => File.dirname(aConfig)}
236
159
  xmlString = MiscUtils.string_from_file(aConfig)
@@ -257,15 +180,10 @@ module YoreCore
257
180
  aCmdOptions.each{|k,v| config_to_read[k.to_sym] = v} if aCmdOptions # merge command options
258
181
  config_to_read.merge!(aOptions) if aOptions # merge options
259
182
  config.read(config_to_read)
260
- config[:basepath] = File.expand_path(Dir.pwd) if !config[:basepath] || config[:basepath]==''
183
+ config[:basepath] = MiscUtils.canonize_path(config[:basepath],Dir.pwd)
261
184
 
262
185
  expand_app_option()
263
186
 
264
- @keepers = Array.new
265
- @keepers << KeepDaily.new(config[:keep_daily])
266
- @keepers << KeepWeekly.new(config[:keep_weekly])
267
- @keepers << KeepMonthly.new(config[:keep_monthly])
268
-
269
187
  @s3client = ::AWSS3Client.new()
270
188
  logger.info "Using S3 key #{@s3client.credentials[:s3_access_key_id]}"
271
189
  end
@@ -310,11 +228,6 @@ module YoreCore
310
228
  filemap
311
229
  end
312
230
 
313
- def keep_file?(aFile)
314
-
315
- end
316
-
317
-
318
231
  # By default, GNU tar suppresses a leading slash on absolute pathnames while creating or reading a tar archive. (You can suppress this with the -p option.)
319
232
  # tar : http://my.safaribooksonline.com/0596102461/I_0596102461_CHP_3_SECT_9#snippet
320
233
 
data/yore.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{yore}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["buzzware"]
12
- s.date = %q{2010-01-15}
12
+ s.date = %q{2010-01-16}
13
13
  s.default_executable = %q{yore}
14
14
  s.description = %q{yore (as in "days of yore") is a user data management utility for web applications.}
15
15
  s.email = %q{contact@buzzware.com.au}
@@ -64,24 +64,21 @@ Gem::Specification.new do |s|
64
64
 
65
65
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
66
66
  s.add_runtime_dependency(%q<cmdparse>, [">= 2.0.2"])
67
- s.add_runtime_dependency(%q<buzzcore>, [">= 0.2.6"])
67
+ s.add_runtime_dependency(%q<buzzcore>, [">= 0.3.1"])
68
68
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.3.3"])
69
- s.add_runtime_dependency(%q<buzzcore>, [">= 0.2.6"])
70
69
  s.add_runtime_dependency(%q<aws-s3>, [">= 0.6.2"])
71
70
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
72
71
  else
73
72
  s.add_dependency(%q<cmdparse>, [">= 2.0.2"])
74
- s.add_dependency(%q<buzzcore>, [">= 0.2.6"])
73
+ s.add_dependency(%q<buzzcore>, [">= 0.3.1"])
75
74
  s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
76
- s.add_dependency(%q<buzzcore>, [">= 0.2.6"])
77
75
  s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
78
76
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
79
77
  end
80
78
  else
81
79
  s.add_dependency(%q<cmdparse>, [">= 2.0.2"])
82
- s.add_dependency(%q<buzzcore>, [">= 0.2.6"])
80
+ s.add_dependency(%q<buzzcore>, [">= 0.3.1"])
83
81
  s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
84
- s.add_dependency(%q<buzzcore>, [">= 0.2.6"])
85
82
  s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
86
83
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
87
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - buzzware
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-15 00:00:00 +08:00
12
+ date: 2010-01-16 00:00:00 +08:00
13
13
  default_executable: yore
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.6
33
+ version: 0.3.1
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: nokogiri
@@ -42,16 +42,6 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.3.3
44
44
  version:
45
- - !ruby/object:Gem::Dependency
46
- name: buzzcore
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 0.2.6
54
- version:
55
45
  - !ruby/object:Gem::Dependency
56
46
  name: aws-s3
57
47
  type: :runtime