Class: CloudBackup::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/driver.rb

Overview

Abstract driver for cloud-backups.

This class is thought as an interface, it encapsulates the abstract logic of a backup and let’s child-classes drivers implement the details of how to communicate to a specific storage engine.

Direct Known Subclasses

LogBackupDriver, RackCloudBackupDriver

Instance Method Summary collapse

Constructor Details

#initializeDriver

Driver Initializer

Each driver will probably have different parameters, api-keys authentication methods etc.

Thus, initialization must be handled/implemented by child classes



19
20
21
# File 'lib/driver.rb', line 19

def initialize
  raise Error.must_define :initialize
end

Instance Method Details

#add_file(path) ⇒ Object

File aggregator

Adds a file to be backed up by the driver, path might be an absolute or relative depending on how you are running your script.

absolute paths are recommendend



40
41
42
43
# File 'lib/driver.rb', line 40

def add_file path
  @files ||= []
  @files << path
end

#initiateObject

Initiate backup

This callback is reserved to initiate server connections or specific per-driver initialization.



28
29
30
# File 'lib/driver.rb', line 28

def initiate
  raise Error.must_define :initiate
end

#listObject

Uncommited files

Returns a list of files that have not been backed up, but were passed by the add_file method. to be backed-up!



50
51
52
# File 'lib/driver.rb', line 50

def list
  @files ||= []
end

#list_by_dateObject

Lists backed-up files ordered by date.

Must return a list of all files that exist in the Remote-Storage-Engine as an array, ordered by date!

Note: (FIFO)



61
62
63
# File 'lib/driver.rb', line 61

def list_by_date
  raise Error.must_define :list_by_date
end

#remove(name) ⇒ Object

Remote resource remover

Deletes a remote resource, normally this is thought to remove resources after new ones are beinng added



70
71
72
# File 'lib/driver.rb', line 70

def remove name
  raise Error.must_define :remove
end

#terminateObject

Termination callback

This method is called after all other methods are called, right before terminating execution. You might wana use this to close connections to remote servers.

Also. Good for notifications!



90
91
92
# File 'lib/driver.rb', line 90

def terminate
  raise Error.must_define :terminate
end

#uploadObject

File uploader.

Uploads all files that were added to the queue



78
79
80
# File 'lib/driver.rb', line 78

def upload
  raise Error.must_define :upload
end