class Backup::Storage::BackBlaze
Different naming to module
Constants
- REQUIRED_ATTRS
Values specified in Model DSL:
-
API credentials
-
bucket name
-
Attributes
part_size[RW]
-
part size for large files
Public Class Methods
new(model, storage_id = nil)
click to toggle source
Calls superclass method
# File lib/backup/backblaze/back_blaze.rb, line 27 def initialize(model, storage_id = nil) super @path ||= '/' check_configuration end
Protected Instance Methods
account()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 103 def account @account ||= begin account_deets = {account_id: account_id} Logger.info "Account login for #{account_deets.inspect}" Backblaze::Account.new account_id: account_id, app_key: app_key end end
check_configuration()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 35 def check_configuration not_specified = REQUIRED_ATTRS.reject{|name| send name} if not_specified.any? raise ConfigurationError, "#{not_specified.join(", ")} required" end if part_size && part_size < account.minimum_part_size raise ConfigurationError, "part_size must be > #{account.minimum_part_size}" end end
remote_relative_pathname()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 46 def remote_relative_pathname @remote_relative_pathname ||= Pathname.new(remote_path).relative_path_from(root) end
remove!(package)
click to toggle source
Called by the Cycler. Any error raised will be logged as a warning.
# File lib/backup/backblaze/back_blaze.rb, line 88 def remove!(package) Logger.info "Removing backup package dated #{package.time}" # workaround for stoopid design in Backup package_remote_relative_pathname = Pathname.new(remote_path(package)).relative_path_from(root) package.filenames.each do |filename| dst = (package_remote_relative_pathname + filename).to_s Logger.info "Removing file #{dst}" account.delete_file bucket, dst end end
root()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 50 def root; @root ||= Pathname.new '/'; end
tmp_dir()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 51 def tmp_dir; @tmp_dir ||= Pathname.new Config.tmp_path; end
transfer!()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 57 def transfer! bucket_id = account.bucket_id bucket_name: bucket package.filenames.each do |filename| dst = (remote_relative_pathname + filename).to_s src_pathname = tmp_dir + filename upload = if src_pathname.size > working_part_size * 2.5 || src_pathname.size > 5 * 10**9 Backblaze::UploadLargeFile.new \ src: src_pathname, dst: dst, account: account, part_size: working_part_size, bucket_id: bucket_id else Backblaze::UploadFile.new \ src: src_pathname.to_s, dst: dst, account: account, bucket_id: bucket_id end hash_wrap = upload.call Logger.info "'#{dst}' stored at #{hash_wrap.fileName}" end end
working_part_size()
click to toggle source
# File lib/backup/backblaze/back_blaze.rb, line 53 def working_part_size @working_part_size ||= part_size || account.recommended_part_size end