class BakFile
Represents files that are either backed up, about to be backed up, or failed to be backed up.
Public Class Methods
delete_from_fs(delete_fid)
click to toggle source
Delete from filesystem using just a fid @return [Bool]
# File lib/bakfile.rb, line 53 def self.delete_from_fs(delete_fid) begin File.delete(PathHelper.path(delete_fid)) rescue Exception => e if $debug raise e end end end
max_fid()
click to toggle source
get the max fid that is backed up
# File lib/bakfile.rb, line 11 def self.max_fid last_backed_file = BakFile.order("fid").last if last_backed_file max_fid = last_backed_file.fid else max_fid = 0 end max_fid end
Public Instance Methods
bak_it()
click to toggle source
Get a file from MogileFS and save it to the destination path. @return [Bool]
# File lib/bakfile.rb, line 37 def bak_it begin path = PathHelper.path(self.fid) $mg.get_file_data(self.dkey, path) rescue Exception => e if $debug raise e end return false end true end
restore()
click to toggle source
Restore
a file back to a MogileFS domain @return [Bool]
# File lib/bakfile.rb, line 23 def restore path = PathHelper.path(self.fid) begin $mg.store_file(self.dkey, self.classname, path) rescue Exception => e if $debug raise e end end end