class Backup::Storage::Local

Public Class Methods

new(model, storage_id = nil) click to toggle source
Calls superclass method Backup::Storage::Base.new
# File lib/backup/storage/local.rb, line 8
def initialize(model, storage_id = nil)
  super

  @path ||= '~/backups'
end

Private Instance Methods

package_movable?() click to toggle source

If this Local Storage is not the last Storage for the Model, force the transfer to use a copy operation and issue a warning.

# File lib/backup/storage/local.rb, line 46
      def package_movable?
        if self == model.storages.last
          true
        else
          Logger.warn Error.new("            Local File Copy Warning!
            The final backup file(s) for '#{ model.label }' (#{ model.trigger })
            will be *copied* to '#{ remote_path }'
            To avoid this, when using more than one Storage, the 'Local' Storage
            should be added *last* so the files may be *moved* to their destination.
")
          false
        end
      end
remote_path(pkg = package) click to toggle source

expanded since this is a local path

Calls superclass method Backup::Storage::Base#remote_path
# File lib/backup/storage/local.rb, line 38
def remote_path(pkg = package)
  File.expand_path(super)
end
Also aliased as: remote_path_for
remote_path_for(pkg = package)
Alias for: remote_path
remove!(package) click to toggle source

Called by the Cycler. Any error raised will be logged as a warning.

# File lib/backup/storage/local.rb, line 31
def remove!(package)
  Logger.info "Removing backup package dated #{ package.time }..."

  FileUtils.rm_r(remote_path_for(package))
end
transfer!() click to toggle source
# File lib/backup/storage/local.rb, line 16
def transfer!
  FileUtils.mkdir_p(remote_path)

  transfer_method = package_movable? ? :mv : :cp
  package.filenames.each do |filename|
    src = File.join(Config.tmp_path, filename)
    dest = File.join(remote_path, filename)
    Logger.info "Storing '#{ dest }'..."

    FileUtils.send(transfer_method, src, dest)
  end
end