class Backup::Storage::Base
Attributes
keep[RW]
Number of backups to keep or time until which to keep.
If an Integer is given it sets the limit to how many backups to keep in the remote location. If exceeded, the oldest will be removed to make room for the newest.
If a Time object is given it will remove backups older than the given date.
@!attribute [rw] keep
@param [Integer|Time] @return [Integer|Time]
model[R]
package[R]
path[RW]
Base path on the remote where backup package files will be stored.
storage_id[R]
Public Class Methods
new(model, storage_id = nil, &block)
click to toggle source
storage_id
is a user-defined string used to uniquely identify
multiple storages of the same type. If multiple storages of the same type
are added to a single backup model, this identifier must be set. This will
be appended to the YAML storage file used for cycling backups.
# File lib/backup/storage/base.rb, line 33 def initialize(model, storage_id = nil, &block) @model = model @package = model.package @storage_id = storage_id.to_s.gsub(/\W/, '_') if storage_id load_defaults! instance_eval(&block) if block_given? end
Public Instance Methods
perform!()
click to toggle source
# File lib/backup/storage/base.rb, line 42 def perform! Logger.info "#{ storage_name } Started..." transfer! if respond_to?(:cycle!, true) && (keep.to_i > 0 || keep.is_a?(Time)) cycle! end Logger.info "#{ storage_name } Finished!" end
Private Instance Methods
remote_path(pkg = package)
click to toggle source
Return the remote path for the current or given package.
# File lib/backup/storage/base.rb, line 55 def remote_path(pkg = package) path.empty? ? File.join(pkg.trigger, pkg.time) : File.join(path, pkg.trigger, pkg.time) end
Also aliased as: remote_path_for
storage_name()
click to toggle source
# File lib/backup/storage/base.rb, line 61 def storage_name @storage_name ||= self.class.to_s.sub('Backup::', '') + (storage_id ? " (#{ storage_id })" : '') end