class Backup::Storage::QiNiu
Attributes
access_key[RW]
bucket[RW]
expires_in[RW]
max_retries[RW]
retry_waitsec[RW]
secret_key[RW]
Public Class Methods
new(model, storage_id = nil)
click to toggle source
Calls superclass method
Backup::Storage::Base::new
# File lib/backup/storage/qi_niu.rb, line 15 def initialize(model, storage_id = nil) super @max_retries ||= 3 @retry_waitsec ||= 30 @path ||= 'backups' path.sub!(/^\//, '') check_configuration end
Private Instance Methods
check_configuration()
click to toggle source
# File lib/backup/storage/qi_niu.rb, line 60 def check_configuration required = %w{ access_key secret_key bucket } raise Error, <<-EOS if required.map {|name| send(name) }.any?(&:nil?) Configuration Error #{ required.map {|name| "##{ name }"}.join(', ') } are all required EOS end
cloud_io()
click to toggle source
# File lib/backup/storage/qi_niu.rb, line 29 def cloud_io @cloud_io ||= CloudIO::QiNiu.new( access_key: access_key, secret_key: secret_key, bucket: bucket, expires_in: expires_in, max_retries: max_retries, retry_waitsec: retry_waitsec ) end
remove!(package)
click to toggle source
# File lib/backup/storage/qi_niu.rb, line 49 def remove!(package) Logger.info "Removing backup package dated #{ package.time }..." remote_path = remote_path_for(package) objects = cloud_io.objects(remote_path) raise Error, "Package at '#{ remote_path }' not found" if objects.empty? cloud_io.delete(objects) end
transfer!()
click to toggle source
# File lib/backup/storage/qi_niu.rb, line 40 def transfer! package.filenames.each do |filename| src = File.join(Config.tmp_path, filename) dest = File.join(remote_path, filename) Logger.info "Storing '#{ bucket }/#{ dest }'..." cloud_io.upload(src, dest) end end