backup 3.0.23 → 3.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. data/Gemfile.lock +42 -45
  2. data/Guardfile +7 -4
  3. data/README.md +10 -7
  4. data/backup.gemspec +2 -2
  5. data/lib/backup.rb +27 -97
  6. data/lib/backup/archive.rb +14 -6
  7. data/lib/backup/cli/helpers.rb +52 -49
  8. data/lib/backup/cli/utility.rb +9 -1
  9. data/lib/backup/compressor/base.rb +10 -4
  10. data/lib/backup/compressor/bzip2.rb +22 -26
  11. data/lib/backup/compressor/custom.rb +53 -0
  12. data/lib/backup/compressor/gzip.rb +22 -23
  13. data/lib/backup/compressor/lzma.rb +15 -13
  14. data/lib/backup/compressor/pbzip2.rb +20 -17
  15. data/lib/backup/config.rb +6 -3
  16. data/lib/backup/configuration.rb +33 -0
  17. data/lib/backup/configuration/helpers.rb +114 -28
  18. data/lib/backup/configuration/store.rb +24 -0
  19. data/lib/backup/database/base.rb +0 -6
  20. data/lib/backup/database/mongodb.rb +27 -11
  21. data/lib/backup/database/mysql.rb +19 -14
  22. data/lib/backup/database/postgresql.rb +16 -11
  23. data/lib/backup/database/redis.rb +7 -11
  24. data/lib/backup/database/riak.rb +3 -6
  25. data/lib/backup/dependency.rb +5 -11
  26. data/lib/backup/model.rb +14 -5
  27. data/lib/backup/notifier/campfire.rb +3 -16
  28. data/lib/backup/notifier/hipchat.rb +1 -7
  29. data/lib/backup/notifier/mail.rb +1 -1
  30. data/lib/backup/packager.rb +29 -19
  31. data/lib/backup/pipeline.rb +110 -0
  32. data/lib/backup/storage/dropbox.rb +4 -7
  33. data/lib/backup/syncer/base.rb +8 -4
  34. data/lib/backup/syncer/cloud/base.rb +247 -0
  35. data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
  36. data/lib/backup/syncer/cloud/s3.rb +68 -0
  37. data/lib/backup/syncer/rsync/base.rb +1 -4
  38. data/lib/backup/syncer/rsync/local.rb +9 -5
  39. data/lib/backup/syncer/rsync/pull.rb +1 -1
  40. data/lib/backup/syncer/rsync/push.rb +10 -5
  41. data/lib/backup/version.rb +1 -1
  42. data/spec-live/.gitignore +6 -0
  43. data/spec-live/README +7 -0
  44. data/spec-live/backups/config.rb +153 -0
  45. data/spec-live/backups/config.yml.template +43 -0
  46. data/spec-live/compressor/custom_spec.rb +30 -0
  47. data/spec-live/compressor/gzip_spec.rb +30 -0
  48. data/spec-live/notifier/mail_spec.rb +85 -0
  49. data/spec-live/spec_helper.rb +85 -0
  50. data/spec-live/storage/dropbox_spec.rb +151 -0
  51. data/spec-live/storage/local_spec.rb +83 -0
  52. data/spec-live/storage/scp_spec.rb +193 -0
  53. data/spec-live/syncer/cloud/s3_spec.rb +124 -0
  54. data/spec/archive_spec.rb +86 -31
  55. data/spec/cleaner_spec.rb +8 -0
  56. data/spec/cli/helpers_spec.rb +200 -75
  57. data/spec/cli/utility_spec.rb +11 -3
  58. data/spec/compressor/base_spec.rb +31 -10
  59. data/spec/compressor/bzip2_spec.rb +212 -57
  60. data/spec/compressor/custom_spec.rb +106 -0
  61. data/spec/compressor/gzip_spec.rb +212 -57
  62. data/spec/compressor/lzma_spec.rb +75 -35
  63. data/spec/compressor/pbzip2_spec.rb +93 -52
  64. data/spec/configuration/helpers_spec.rb +406 -0
  65. data/spec/configuration/store_spec.rb +39 -0
  66. data/spec/configuration_spec.rb +62 -0
  67. data/spec/database/base_spec.rb +19 -10
  68. data/spec/database/mongodb_spec.rb +195 -70
  69. data/spec/database/mysql_spec.rb +183 -64
  70. data/spec/database/postgresql_spec.rb +167 -53
  71. data/spec/database/redis_spec.rb +121 -46
  72. data/spec/database/riak_spec.rb +96 -27
  73. data/spec/dependency_spec.rb +2 -0
  74. data/spec/encryptor/base_spec.rb +10 -0
  75. data/spec/encryptor/gpg_spec.rb +29 -13
  76. data/spec/encryptor/open_ssl_spec.rb +40 -21
  77. data/spec/logger_spec.rb +4 -0
  78. data/spec/model_spec.rb +19 -2
  79. data/spec/notifier/base_spec.rb +32 -17
  80. data/spec/notifier/campfire_spec.rb +63 -45
  81. data/spec/notifier/hipchat_spec.rb +79 -56
  82. data/spec/notifier/mail_spec.rb +82 -46
  83. data/spec/notifier/prowl_spec.rb +53 -32
  84. data/spec/notifier/twitter_spec.rb +62 -41
  85. data/spec/packager_spec.rb +95 -36
  86. data/spec/pipeline_spec.rb +259 -0
  87. data/spec/spec_helper.rb +6 -5
  88. data/spec/storage/base_spec.rb +61 -41
  89. data/spec/storage/cloudfiles_spec.rb +69 -45
  90. data/spec/storage/dropbox_spec.rb +158 -36
  91. data/spec/storage/ftp_spec.rb +69 -45
  92. data/spec/storage/local_spec.rb +47 -23
  93. data/spec/storage/ninefold_spec.rb +55 -31
  94. data/spec/storage/rsync_spec.rb +67 -50
  95. data/spec/storage/s3_spec.rb +65 -41
  96. data/spec/storage/scp_spec.rb +65 -41
  97. data/spec/storage/sftp_spec.rb +65 -41
  98. data/spec/syncer/base_spec.rb +91 -4
  99. data/spec/syncer/cloud/base_spec.rb +511 -0
  100. data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
  101. data/spec/syncer/cloud/s3_spec.rb +174 -0
  102. data/spec/syncer/rsync/base_spec.rb +46 -66
  103. data/spec/syncer/rsync/local_spec.rb +55 -26
  104. data/spec/syncer/rsync/pull_spec.rb +15 -4
  105. data/spec/syncer/rsync/push_spec.rb +59 -52
  106. data/templates/cli/utility/compressor/bzip2 +1 -4
  107. data/templates/cli/utility/compressor/custom +11 -0
  108. data/templates/cli/utility/compressor/gzip +1 -4
  109. data/templates/cli/utility/compressor/lzma +3 -0
  110. data/templates/cli/utility/compressor/pbzip2 +3 -0
  111. data/templates/cli/utility/database/mysql +4 -1
  112. data/templates/cli/utility/syncer/cloud_files +17 -19
  113. data/templates/cli/utility/syncer/s3 +18 -20
  114. metadata +38 -92
  115. data/lib/backup/configuration/base.rb +0 -15
  116. data/lib/backup/configuration/compressor/base.rb +0 -9
  117. data/lib/backup/configuration/compressor/bzip2.rb +0 -23
  118. data/lib/backup/configuration/compressor/gzip.rb +0 -23
  119. data/lib/backup/configuration/compressor/lzma.rb +0 -23
  120. data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
  121. data/lib/backup/configuration/database/base.rb +0 -19
  122. data/lib/backup/configuration/database/mongodb.rb +0 -49
  123. data/lib/backup/configuration/database/mysql.rb +0 -42
  124. data/lib/backup/configuration/database/postgresql.rb +0 -41
  125. data/lib/backup/configuration/database/redis.rb +0 -39
  126. data/lib/backup/configuration/database/riak.rb +0 -29
  127. data/lib/backup/configuration/encryptor/base.rb +0 -9
  128. data/lib/backup/configuration/encryptor/gpg.rb +0 -17
  129. data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
  130. data/lib/backup/configuration/notifier/base.rb +0 -28
  131. data/lib/backup/configuration/notifier/campfire.rb +0 -25
  132. data/lib/backup/configuration/notifier/hipchat.rb +0 -41
  133. data/lib/backup/configuration/notifier/mail.rb +0 -112
  134. data/lib/backup/configuration/notifier/presently.rb +0 -25
  135. data/lib/backup/configuration/notifier/prowl.rb +0 -23
  136. data/lib/backup/configuration/notifier/twitter.rb +0 -21
  137. data/lib/backup/configuration/storage/base.rb +0 -18
  138. data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
  139. data/lib/backup/configuration/storage/dropbox.rb +0 -58
  140. data/lib/backup/configuration/storage/ftp.rb +0 -29
  141. data/lib/backup/configuration/storage/local.rb +0 -17
  142. data/lib/backup/configuration/storage/ninefold.rb +0 -20
  143. data/lib/backup/configuration/storage/rsync.rb +0 -29
  144. data/lib/backup/configuration/storage/s3.rb +0 -25
  145. data/lib/backup/configuration/storage/scp.rb +0 -25
  146. data/lib/backup/configuration/storage/sftp.rb +0 -25
  147. data/lib/backup/configuration/syncer/base.rb +0 -10
  148. data/lib/backup/configuration/syncer/cloud.rb +0 -23
  149. data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
  150. data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
  151. data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
  152. data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
  153. data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
  154. data/lib/backup/configuration/syncer/s3.rb +0 -23
  155. data/lib/backup/notifier/presently.rb +0 -88
  156. data/lib/backup/syncer/cloud.rb +0 -187
  157. data/lib/backup/syncer/cloud_files.rb +0 -56
  158. data/lib/backup/syncer/s3.rb +0 -47
  159. data/spec/configuration/base_spec.rb +0 -35
  160. data/spec/configuration/compressor/bzip2_spec.rb +0 -29
  161. data/spec/configuration/compressor/gzip_spec.rb +0 -29
  162. data/spec/configuration/compressor/lzma_spec.rb +0 -29
  163. data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
  164. data/spec/configuration/database/base_spec.rb +0 -17
  165. data/spec/configuration/database/mongodb_spec.rb +0 -56
  166. data/spec/configuration/database/mysql_spec.rb +0 -53
  167. data/spec/configuration/database/postgresql_spec.rb +0 -53
  168. data/spec/configuration/database/redis_spec.rb +0 -50
  169. data/spec/configuration/database/riak_spec.rb +0 -35
  170. data/spec/configuration/encryptor/gpg_spec.rb +0 -26
  171. data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
  172. data/spec/configuration/notifier/base_spec.rb +0 -32
  173. data/spec/configuration/notifier/campfire_spec.rb +0 -32
  174. data/spec/configuration/notifier/hipchat_spec.rb +0 -44
  175. data/spec/configuration/notifier/mail_spec.rb +0 -71
  176. data/spec/configuration/notifier/presently_spec.rb +0 -35
  177. data/spec/configuration/notifier/prowl_spec.rb +0 -29
  178. data/spec/configuration/notifier/twitter_spec.rb +0 -35
  179. data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
  180. data/spec/configuration/storage/dropbox_spec.rb +0 -38
  181. data/spec/configuration/storage/ftp_spec.rb +0 -44
  182. data/spec/configuration/storage/local_spec.rb +0 -29
  183. data/spec/configuration/storage/ninefold_spec.rb +0 -32
  184. data/spec/configuration/storage/rsync_spec.rb +0 -41
  185. data/spec/configuration/storage/s3_spec.rb +0 -38
  186. data/spec/configuration/storage/scp_spec.rb +0 -41
  187. data/spec/configuration/storage/sftp_spec.rb +0 -41
  188. data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
  189. data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
  190. data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
  191. data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
  192. data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
  193. data/spec/configuration/syncer/s3_spec.rb +0 -38
  194. data/spec/notifier/presently_spec.rb +0 -181
  195. data/spec/syncer/cloud_files_spec.rb +0 -192
  196. data/spec/syncer/s3_spec.rb +0 -192
  197. data/templates/cli/utility/notifier/presently +0 -13
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Backup
4
- module Configuration
5
- module Syncer
6
- module RSync
7
- class Local < Base; end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Backup
4
- module Configuration
5
- module Syncer
6
- module RSync
7
- class Pull < Push; end
8
- end
9
- end
10
- end
11
- end
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Backup
4
- module Configuration
5
- module Syncer
6
- module RSync
7
- class Push < Base
8
- class << self
9
-
10
- ##
11
- # Server credentials
12
- attr_accessor :username, :password
13
-
14
- ##
15
- # Server IP Address and SSH port
16
- attr_accessor :ip
17
-
18
- ##
19
- # The SSH port to connect to
20
- attr_accessor :port
21
-
22
- ##
23
- # Flag for compressing (only compresses for the transfer)
24
- attr_accessor :compress
25
-
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Backup
4
- module Configuration
5
- module Syncer
6
- class S3 < Cloud
7
- class << self
8
- ##
9
- # Amazon Simple Storage Service (S3) Credentials
10
- attr_accessor :access_key_id, :secret_access_key
11
-
12
- ##
13
- # The S3 bucket to store files to
14
- attr_accessor :bucket
15
-
16
- ##
17
- # The AWS region of the specified S3 bucket
18
- attr_accessor :region
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,88 +0,0 @@
1
- # encoding: utf-8
2
-
3
- Backup::Dependency.load('httparty')
4
-
5
- module Backup
6
- module Notifier
7
- class Presently < Base
8
-
9
- ##
10
- # Presently subdomain
11
- attr_accessor :subdomain
12
-
13
- ##
14
- # Presently credentials
15
- attr_accessor :user_name, :password
16
-
17
- ##
18
- # Group id
19
- attr_accessor :group_id
20
-
21
- def initialize(model, &block)
22
- super(model)
23
-
24
- instance_eval(&block) if block_given?
25
- end
26
-
27
- private
28
-
29
- ##
30
- # Notify the user of the backup operation results.
31
- # `status` indicates one of the following:
32
- #
33
- # `:success`
34
- # : The backup completed successfully.
35
- # : Notification will be sent if `on_success` was set to `true`
36
- #
37
- # `:warning`
38
- # : The backup completed successfully, but warnings were logged
39
- # : Notification will be sent, including a copy of the current
40
- # : backup log, if `on_warning` was set to `true`
41
- #
42
- # `:failure`
43
- # : The backup operation failed.
44
- # : Notification will be sent, including the Exception which caused
45
- # : the failure, the Exception's backtrace, a copy of the current
46
- # : backup log and other information if `on_failure` was set to `true`
47
- #
48
- def notify!(status)
49
- name = case status
50
- when :success then 'Success'
51
- when :warning then 'Warning'
52
- when :failure then 'Failure'
53
- end
54
- message = "[Backup::%s] #{@model.label} (#{@model.trigger})" % name
55
- send_message(message)
56
- end
57
-
58
- def send_message(message)
59
- client = Client.new(subdomain, user_name, password, group_id)
60
- client.update(message)
61
- end
62
-
63
- class Client
64
- include HTTParty
65
-
66
- attr_accessor :subdomain, :user_name, :password, :group_id
67
-
68
- def initialize(subdomain, user_name, password, group_id)
69
- @subdomain = subdomain
70
- @user_name = user_name
71
- @password = password
72
- @group_id = group_id
73
-
74
- self.class.base_uri "https://#{subdomain}.presently.com"
75
- self.class.basic_auth user_name, password
76
- end
77
-
78
- def update(message)
79
- message = "d @#{group_id} #{message}" if group_id
80
- self.class.post "/api/twitter/statuses/update.json", :body => {
81
- :status => message,
82
- :source => "Backup Notifier"
83
- }
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,187 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ##
4
- # Only load the Fog gem, along with the Parallel gem, when the Backup::Syncer::Cloud class is loaded
5
- Backup::Dependency.load('fog')
6
- Backup::Dependency.load('parallel')
7
-
8
- module Backup
9
- module Syncer
10
- class Cloud < Base
11
-
12
- ##
13
- # Create a Mutex to synchronize certain parts of the code
14
- # in order to prevent race conditions or broken STDOUT.
15
- MUTEX = Mutex.new
16
-
17
- ##
18
- # Concurrency setting - defaults to false, but can be set to:
19
- # - :threads
20
- # - :processes
21
- attr_accessor :concurrency_type
22
-
23
- ##
24
- # Concurrency level - the number of threads or processors to use. Defaults to 2.
25
- attr_accessor :concurrency_level
26
-
27
- ##
28
- # Instantiates a new Cloud Syncer object and sets the default
29
- # configuration specified in the Backup::Configuration::Syncer::S3. Then
30
- # it sets the object defaults if particular properties weren't set.
31
- # Finally it'll evaluate the users configuration file and overwrite
32
- # anything that's been defined.
33
- def initialize(&block)
34
- load_defaults!
35
-
36
- @path ||= 'backups'
37
- @directories ||= Array.new
38
- @mirror ||= false
39
- @concurrency_type = false
40
- @concurrency_level = 2
41
-
42
- instance_eval(&block) if block_given?
43
-
44
- @path = path.sub(/^\//, '')
45
- end
46
-
47
- ##
48
- # Performs the Sync operation
49
- def perform!
50
- Logger.message("#{ self.class } started the syncing process:")
51
-
52
- directories.each do |directory|
53
- SyncContext.new(directory, repository_object, path).
54
- sync! mirror, concurrency_type, concurrency_level
55
- end
56
- end
57
-
58
- private
59
-
60
- class SyncContext
61
- attr_reader :directory, :bucket, :path
62
-
63
- ##
64
- # Creates a new SyncContext object which handles a single directory
65
- # from the Syncer::Base @directories array.
66
- def initialize(directory, bucket, path)
67
- @directory, @bucket, @path = directory, bucket, path
68
- end
69
-
70
- ##
71
- # Performs the sync operation using the provided techniques (mirroring/concurrency).
72
- def sync!(mirror = false, concurrency_type = false, concurrency_level = 2)
73
- block = Proc.new { |relative_path| sync_file relative_path, mirror }
74
-
75
- case concurrency_type
76
- when FalseClass
77
- all_file_names.each &block
78
- when :threads
79
- Parallel.each all_file_names, :in_threads => concurrency_level, &block
80
- when :processes
81
- Parallel.each all_file_names, :in_processes => concurrency_level, &block
82
- else
83
- raise "Unknown concurrency_type setting: #{concurrency_type.inspect}"
84
- end
85
- end
86
-
87
- private
88
-
89
- ##
90
- # Gathers all the remote and local file name and merges them together, removing
91
- # duplicate keys if any, and sorts the in alphabetical order.
92
- def all_file_names
93
- @all_file_names ||= (local_files.keys | remote_files.keys).sort
94
- end
95
-
96
- ##
97
- # Returns a Hash of local files (the keys are the filesystem paths,
98
- # the values are the LocalFile objects for that given file)
99
- def local_files
100
- @local_files ||= begin
101
- local_hashes.split("\n").collect { |line|
102
- LocalFile.new directory, line
103
- }.inject({}) { |hash, file|
104
- hash[file.relative_path] = file
105
- hash
106
- }
107
- end
108
- end
109
-
110
- ##
111
- # Returns a String of file paths and their md5 hashes.
112
- def local_hashes
113
- MUTEX.synchronize { Logger.message("\s\sGenerating checksums for #{ directory }") }
114
- `find #{directory} -print0 | xargs -0 openssl md5 2> /dev/null`
115
- end
116
-
117
- ##
118
- # Returns a Hash of remote files (the keys are the remote paths,
119
- # the values are the Fog file objects for that given file)
120
- def remote_files
121
- @remote_files ||= bucket.files.to_a.select { |file|
122
- file.key[%r{^#{remote_base}/}]
123
- }.inject({}) { |hash, file|
124
- key = file.key.gsub(/^#{remote_base}\//,
125
- "#{directory.split('/').last}/")
126
- hash[key] = file
127
- hash
128
- }
129
- end
130
-
131
- ##
132
- # Creates and returns a String that represents the base remote storage path
133
- def remote_base
134
- @remote_base ||= [path, directory.split('/').last].select { |part|
135
- part && part.strip.length > 0
136
- }.join('/')
137
- end
138
-
139
- ##
140
- # Performs a sync operation on a file. When mirroring is enabled
141
- # and a local file has been removed since the last sync, it will also
142
- # remove it from the remote location. It will no upload files that
143
- # have not changed since the last sync. Checks are done using an md5 hash.
144
- # If a file has changed, or has been newly added, the file will be transferred/overwritten.
145
- def sync_file(relative_path, mirror)
146
- local_file = local_files[relative_path]
147
- remote_file = remote_files[relative_path]
148
-
149
- if local_file && File.exist?(local_file.path)
150
- unless remote_file && remote_file.etag == local_file.md5
151
- MUTEX.synchronize { Logger.message("\s\s[transferring] #{relative_path}") }
152
- bucket.files.create(
153
- :key => "#{path}/#{relative_path}".gsub(/^\//, ''),
154
- :body => File.open(local_file.path)
155
- )
156
- else
157
- MUTEX.synchronize { Logger.message("\s\s[skipping] #{relative_path}") }
158
- end
159
- elsif remote_file && mirror
160
- MUTEX.synchronize { Logger.message("\s\s[removing] #{relative_path}") }
161
- remote_file.destroy
162
- end
163
- end
164
- end
165
-
166
- class LocalFile
167
- attr_reader :directory, :path, :md5
168
-
169
- ##
170
- # Creates a new LocalFile object using the given directory and line
171
- # from the md5 hash checkup. This object figures out the path, relative_path and md5 hash
172
- # for the file.
173
- def initialize(directory, line)
174
- @directory = directory
175
- @path, @md5 = *line.chomp.match(/^MD5\(([^\)]+)\)= (\w+)$/).captures
176
- end
177
-
178
- ##
179
- # Returns the relative path to the file.
180
- def relative_path
181
- @relative_path ||= path.gsub %r{^#{directory}},
182
- directory.split('/').last
183
- end
184
- end
185
- end
186
- end
187
- end
@@ -1,56 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Backup
4
- module Syncer
5
- class CloudFiles < Cloud
6
-
7
- ##
8
- # Rackspace CloudFiles Credentials
9
- attr_accessor :api_key, :username
10
-
11
- ##
12
- # Rackspace CloudFiles Container
13
- attr_accessor :container
14
-
15
- ##
16
- # Rackspace AuthURL allows you to connect to a different Rackspace datacenter
17
- # - https://auth.api.rackspacecloud.com (Default: US)
18
- # - https://lon.auth.api.rackspacecloud.com (UK)
19
- attr_accessor :auth_url
20
-
21
- ##
22
- # Improve performance and avoid data transfer costs by setting @servicenet to `true`
23
- # This only works if Backup runs on a Rackspace server
24
- attr_accessor :servicenet
25
-
26
- private
27
-
28
- ##
29
- # Established and creates a new Fog storage object for CloudFiles.
30
- def connection
31
- @connection ||= Fog::Storage.new(
32
- :provider => provider,
33
- :rackspace_username => username,
34
- :rackspace_api_key => api_key,
35
- :rackspace_auth_url => auth_url,
36
- :rackspace_servicenet => servicenet
37
- )
38
- end
39
-
40
- ##
41
- # Creates a new @repository_object (container). Fetches it from Cloud Files
42
- # if it already exists, otherwise it will create it first and fetch use that instead.
43
- def repository_object
44
- @repository_object ||= connection.directories.get(container) ||
45
- connection.directories.create(:key => container)
46
- end
47
-
48
- ##
49
- # This is the provider that Fog uses for the Cloud Files
50
- def provider
51
- "Rackspace"
52
- end
53
-
54
- end
55
- end
56
- end
@@ -1,47 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Backup
4
- module Syncer
5
- class S3 < Cloud
6
-
7
- ##
8
- # Amazon Simple Storage Service (S3) Credentials
9
- attr_accessor :access_key_id, :secret_access_key
10
-
11
- ##
12
- # The S3 bucket to store files to
13
- attr_accessor :bucket
14
-
15
- ##
16
- # The AWS region of the specified S3 bucket
17
- attr_accessor :region
18
-
19
- private
20
-
21
- ##
22
- # Established and creates a new Fog storage object for S3.
23
- def connection
24
- @connection ||= Fog::Storage.new(
25
- :provider => provider,
26
- :aws_access_key_id => access_key_id,
27
- :aws_secret_access_key => secret_access_key,
28
- :region => region
29
- )
30
- end
31
-
32
- ##
33
- # Creates a new @repository_object (bucket). Fetches it from S3
34
- # if it already exists, otherwise it will create it first and fetch use that instead.
35
- def repository_object
36
- @repository_object ||= connection.directories.get(bucket) ||
37
- connection.directories.create(:key => bucket, :location => region)
38
- end
39
-
40
- ##
41
- # This is the provider that Fog uses for the Cloud Files
42
- def provider
43
- "AWS"
44
- end
45
- end
46
- end
47
- end