Class: Backup2s3

Inherits:
Object
  • Object
show all
Includes:
System
Defined in:
lib/backup2s3.rb

Constant Summary collapse

POSTGRESQL =
'postgresql'
MYSQL =
'mysql'

Instance Method Summary collapse

Methods included from System

clean, db_credentials, hostname, prompt, run, tarzip_folders, unzip_file

Constructor Details

#initializeBackup2s3

Returns a new instance of Backup2s3.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/backup2s3.rb', line 20

def initialize
  STDOUT.sync = true #used so that print will not buffer output
  #ActiveResource::Base.logger = true
  load_configuration
  load_s3_adapter
  load_db_adapter
  load_backup_manager
  @database_file = ""
  @application_file = ""
  @time = Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create(comment = ENV['comment']) ⇒ Object

CREATE creates a backup



34
35
36
37
# File 'lib/backup2s3.rb', line 34

def create(comment = ENV['comment'])
  create_backup(comment)
  save_backup_manager
end

#delete(backup_id = ENV['id']) ⇒ Object

DELETE deletes a backup



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

def delete(backup_id = ENV['id'])
  raise "id is blank! There was no backup specified for deletion." and return if backup_id == nil
  delete_backup(backup_id)
  save_backup_manager
end

#listObject

LIST



54
55
56
# File 'lib/backup2s3.rb', line 54

def list
  @backup_manager.list_backups
end

#restore(backup_id = ENV['id']) ⇒ Object

RESTORE restores a backup



47
48
49
50
51
# File 'lib/backup2s3.rb', line 47

def restore(backup_id = ENV['id'])
  raise "id is blank! There was no backup specified for restoration." and return if backup_id == nil
  restore_backup(backup_id)
  save_backup_manager
end