backup 2.3.2.pre2 → 2.3.2.pre3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.3.2.pre2
data/bin/backup CHANGED
@@ -23,13 +23,14 @@ optparse = OptionParser.new do |opts|
23
23
  backup = Backup::Setup.new(trigger, @backup_procedures)
24
24
  records = Array.new
25
25
  case backup.procedure.storage_name.to_sym
26
- when :s3 then records = Backup::Record::S3.all :conditions => {:trigger => trigger}
27
- when :scp then records = Backup::Record::SCP.all :conditions => {:trigger => trigger}
28
- when :ftp then records = Backup::Record::FTP.all :conditions => {:trigger => trigger}
29
- when :sftp then records = Backup::Record::SFTP.all :conditions => {:trigger => trigger}
30
- when :local then records = Backup::Record::Local.all :conditions => {:trigger => trigger}
26
+ when :cloudfiles then records = Backup::Record::CloudFiles.all :conditions => {:trigger => trigger}
27
+ when :s3 then records = Backup::Record::S3.all :conditions => {:trigger => trigger}
28
+ when :scp then records = Backup::Record::SCP.all :conditions => {:trigger => trigger}
29
+ when :ftp then records = Backup::Record::FTP.all :conditions => {:trigger => trigger}
30
+ when :sftp then records = Backup::Record::SFTP.all :conditions => {:trigger => trigger}
31
+ when :local then records = Backup::Record::Local.all :conditions => {:trigger => trigger}
31
32
  end
32
-
33
+
33
34
  if options[:table]
34
35
  puts Hirb::Helpers::AutoTable.render(records)
35
36
  else
@@ -49,11 +50,12 @@ optparse = OptionParser.new do |opts|
49
50
  puts "Destroying backup records with trigger: #{trigger}."
50
51
  backup = Backup::Setup.new(trigger, @backup_procedures)
51
52
  case backup.procedure.storage_name.to_sym
52
- when :s3 then Backup::Record::S3.destroy_all_backups backup.procedure, trigger
53
- when :scp then Backup::Record::SCP.destroy_all_backups backup.procedure, trigger
54
- when :ftp then Backup::Record::FTP.destroy_all_backups backup.procedure, trigger
55
- when :sftp then Backup::Record::SFTP.destroy_all_backups backup.procedure, trigger
56
- when :local then Backup::Record::Local.destroy_all_backups backup.procedure, trigger
53
+ when :cloudfiles then Backup::Record::CloudFiles.destroy_all_backups backup.procedure, trigger
54
+ when :s3 then Backup::Record::S3.destroy_all_backups backup.procedure, trigger
55
+ when :scp then Backup::Record::SCP.destroy_all_backups backup.procedure, trigger
56
+ when :ftp then Backup::Record::FTP.destroy_all_backups backup.procedure, trigger
57
+ when :sftp then Backup::Record::SFTP.destroy_all_backups backup.procedure, trigger
58
+ when :local then Backup::Record::Local.destroy_all_backups backup.procedure, trigger
57
59
  end
58
60
  end
59
61
 
@@ -68,11 +70,12 @@ optparse = OptionParser.new do |opts|
68
70
  backup = Backup::Setup.new(false, @backup_procedures)
69
71
  backup.procedures.each do |backup_procedure|
70
72
  case backup_procedure.storage_name.to_sym
71
- when :s3 then Backup::Record::S3.destroy_all_backups backup_procedure, backup_procedure.trigger
72
- when :scp then Backup::Record::SCP.destroy_all_backups backup_procedure, backup_procedure.trigger
73
- when :ftp then Backup::Record::FTP.destroy_all_backups backup_procedure, backup_procedure.trigger
74
- when :sftp then Backup::Record::SFTP.destroy_all_backups backup_procedure, backup_procedure.trigger
75
- when :local then Backup::Record::Local.destroy_all_backups backup.procedure, backup_procedure.trigger
73
+ when :cloudfiles then Backup::Record::CloudFiles.destroy_all_backups backup_procedure, backup_procedure.trigger
74
+ when :s3 then Backup::Record::S3.destroy_all_backups backup_procedure, backup_procedure.trigger
75
+ when :scp then Backup::Record::SCP.destroy_all_backups backup_procedure, backup_procedure.trigger
76
+ when :ftp then Backup::Record::FTP.destroy_all_backups backup_procedure, backup_procedure.trigger
77
+ when :sftp then Backup::Record::SFTP.destroy_all_backups backup_procedure, backup_procedure.trigger
78
+ when :local then Backup::Record::Local.destroy_all_backups backup.procedure, backup_procedure.trigger
76
79
  end
77
80
  end
78
81
  end
data/lib/backup.rb CHANGED
@@ -51,20 +51,22 @@ module Backup
51
51
  end
52
52
 
53
53
  module Storage
54
- autoload :S3, 'backup/storage/s3'
55
- autoload :SCP, 'backup/storage/scp'
56
- autoload :FTP, 'backup/storage/ftp'
57
- autoload :SFTP, 'backup/storage/sftp'
58
- autoload :Local, 'backup/storage/local'
54
+ autoload :CloudFiles, 'backup/storage/cloudfiles'
55
+ autoload :S3, 'backup/storage/s3'
56
+ autoload :SCP, 'backup/storage/scp'
57
+ autoload :FTP, 'backup/storage/ftp'
58
+ autoload :SFTP, 'backup/storage/sftp'
59
+ autoload :Local, 'backup/storage/local'
59
60
  end
60
61
 
61
62
  module Record
62
- autoload :Base, 'backup/record/base'
63
- autoload :S3, 'backup/record/s3'
64
- autoload :SCP, 'backup/record/scp'
65
- autoload :FTP, 'backup/record/ftp'
66
- autoload :SFTP, 'backup/record/sftp'
67
- autoload :Local, 'backup/record/local'
63
+ autoload :Base, 'backup/record/base'
64
+ autoload :CloudFiles, 'backup/record/cloudfiles'
65
+ autoload :S3, 'backup/record/s3'
66
+ autoload :SCP, 'backup/record/scp'
67
+ autoload :FTP, 'backup/record/ftp'
68
+ autoload :SFTP, 'backup/record/sftp'
69
+ autoload :Local, 'backup/record/local'
68
70
  end
69
71
 
70
72
  class Setup
@@ -25,21 +25,23 @@ module Backup
25
25
  # Initializes the storing process depending on the store settings
26
26
  def initialize_storage(adapter)
27
27
  case @storage_name.to_sym
28
- when :s3 then Backup::Storage::S3.new(adapter)
29
- when :scp then Backup::Storage::SCP.new(adapter)
30
- when :ftp then Backup::Storage::FTP.new(adapter)
31
- when :sftp then Backup::Storage::SFTP.new(adapter)
32
- when :local then Backup::Storage::Local.new(adapter)
28
+ when :cloudfiles then Backup::Storage::CloudFiles.new(adapter)
29
+ when :s3 then Backup::Storage::S3.new(adapter)
30
+ when :scp then Backup::Storage::SCP.new(adapter)
31
+ when :ftp then Backup::Storage::FTP.new(adapter)
32
+ when :sftp then Backup::Storage::SFTP.new(adapter)
33
+ when :local then Backup::Storage::Local.new(adapter)
33
34
  end
34
35
  end
35
36
 
36
37
  def initialize_record
37
38
  case @storage_name.to_sym
38
- when :s3 then Backup::Record::S3.new
39
- when :scp then Backup::Record::SCP.new
40
- when :ftp then Backup::Record::FTP.new
41
- when :sftp then Backup::Record::SFTP.new
42
- when :local then Backup::Record::Local.new
39
+ when :cloudfiles then Backup::Record::CloudFiles.new
40
+ when :s3 then Backup::Record::S3.new
41
+ when :scp then Backup::Record::SCP.new
42
+ when :ftp then Backup::Record::FTP.new
43
+ when :sftp then Backup::Record::SFTP.new
44
+ when :local then Backup::Record::Local.new
43
45
  end
44
46
  end
45
47
 
@@ -2,7 +2,7 @@ module Backup
2
2
  module Configuration
3
3
  class Storage
4
4
  extend Backup::Configuration::Attributes
5
- generate_attributes %w(ip user password path access_key_id secret_access_key use_ssl bucket)
5
+ generate_attributes %w(ip user password path access_key_id secret_access_key use_ssl bucket username api_key container)
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,75 @@
1
+ require 'cloudfiles'
2
+
3
+ module Backup
4
+ module Connection
5
+ class CloudFiles
6
+
7
+ attr_accessor :adapter, :procedure, :api_key, :username, :cf_container, :final_file, :tmp_path
8
+
9
+ # Initializes the Cloud Files connection, setting the values using the
10
+ # Cloud Files adapter
11
+ def initialize(adapter = false)
12
+ if adapter
13
+ self.adapter = adapter
14
+ self.procedure = adapter.procedure
15
+ self.final_file = adapter.final_file
16
+ self.tmp_path = adapter.tmp_path.gsub('\ ', ' ')
17
+ load_storage_configuration_attributes
18
+ end
19
+ end
20
+
21
+ # Sets values from a procedure, rather than from the adapter object
22
+ def static_initialize(procedure)
23
+ self.procedure = procedure
24
+ load_storage_configuration_attributes(true)
25
+ end
26
+
27
+ # Establishes a connection with Rackspace Cloud Files using the
28
+ # credentials provided by the user
29
+ def connect
30
+ connection
31
+ end
32
+
33
+ # Wrapper for the Connection object
34
+ def connection
35
+ ::CloudFiles::Connection.new(username, api_key)
36
+ end
37
+
38
+ # Wrapper for the Container object
39
+ def container
40
+ connection.container(cf_container)
41
+ end
42
+
43
+ # Initializes the file transfer to Rackspace Cloud Files
44
+ # This can only run after a connection has been made using the #connect method
45
+ def store
46
+ object = container.create_object(final_file)
47
+ object.write(open(File.join(tmp_path, final_file)))
48
+ end
49
+
50
+ # Destroys file from a bucket on Amazon S3
51
+ def destroy(file, c)
52
+ c = connection.container(c)
53
+ c.delete_object(file)
54
+ end
55
+
56
+ private
57
+
58
+ def load_storage_configuration_attributes(static = false)
59
+ %w(api_key username).each do |attribute|
60
+ if static
61
+ send("#{attribute}=", procedure.get_storage_configuration.attributes[attribute])
62
+ else
63
+ send("#{attribute}=", adapter.procedure.get_storage_configuration.attributes[attribute])
64
+ end
65
+ end
66
+
67
+ if static
68
+ self.cf_container = procedure.get_storage_configuration.attributes['container']
69
+ else
70
+ self.cf_container = adapter.procedure.get_storage_configuration.attributes['container']
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,28 @@
1
+ require 'backup/connection/cloudfiles'
2
+
3
+ module Backup
4
+ module Record
5
+ class CloudFiles < Backup::Record::Base
6
+
7
+ alias_attribute :container, :bucket
8
+
9
+ def load_specific_settings(adapter)
10
+ self.container = adapter.procedure.get_storage_configuration.attributes['container']
11
+ end
12
+
13
+ private
14
+
15
+ def self.destroy_backups(procedure, backups)
16
+ cf = Backup::Connection::CloudFiles.new
17
+ cf.static_initialize(procedure)
18
+ cf.connect
19
+ backups.each do |backup|
20
+ puts "\nDestroying backup \"#{backup.filename}\" from container \"#{backup.container}\"."
21
+ cf.destroy(backup.filename, backup.container)
22
+ backup.destroy
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ require 'backup/connection/cloudfiles'
2
+
3
+ module Backup
4
+ module Storage
5
+ class CloudFiles
6
+
7
+ # Stores the backup file on the remote server using Rackspace Cloud Files
8
+ def initialize(adapter)
9
+ cf = Backup::Connection::CloudFiles.new(adapter)
10
+ cf.connect
11
+ cf.store
12
+ end
13
+
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1876988207
4
+ hash: -1876988210
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
9
  - 2
10
- - pre2
11
- version: 2.3.2.pre2
10
+ - pre3
11
+ version: 2.3.2.pre3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Michael van Rooijen
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-11 00:00:00 +02:00
19
+ date: 2010-07-14 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -146,6 +146,22 @@ dependencies:
146
146
  version: "0.5"
147
147
  type: :runtime
148
148
  version_requirements: *id008
149
+ - !ruby/object:Gem::Dependency
150
+ name: cloudfiles
151
+ prerelease: false
152
+ requirement: &id009 !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 9
158
+ segments:
159
+ - 1
160
+ - 4
161
+ - 7
162
+ version: 1.4.7
163
+ type: :runtime
164
+ version_requirements: *id009
149
165
  description: |-
150
166
  Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the
151
167
  Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as
@@ -179,6 +195,7 @@ files:
179
195
  - lib/backup/configuration/mail.rb
180
196
  - lib/backup/configuration/smtp.rb
181
197
  - lib/backup/configuration/storage.rb
198
+ - lib/backup/connection/cloudfiles.rb
182
199
  - lib/backup/connection/s3.rb
183
200
  - lib/backup/environment/base.rb
184
201
  - lib/backup/environment/rails.rb
@@ -186,11 +203,13 @@ files:
186
203
  - lib/backup/mail/base.rb
187
204
  - lib/backup/mail/mail.txt
188
205
  - lib/backup/record/base.rb
206
+ - lib/backup/record/cloudfiles.rb
189
207
  - lib/backup/record/ftp.rb
190
208
  - lib/backup/record/local.rb
191
209
  - lib/backup/record/s3.rb
192
210
  - lib/backup/record/scp.rb
193
211
  - lib/backup/record/sftp.rb
212
+ - lib/backup/storage/cloudfiles.rb
194
213
  - lib/backup/storage/ftp.rb
195
214
  - lib/backup/storage/local.rb
196
215
  - lib/backup/storage/s3.rb