Module: Backs3

Included in:
Backup, FileInfo, Restore
Defined in:
lib/backs3/version.rb,
lib/backs3.rb,
lib/backs3/backs3.rb,
lib/backs3/backup.rb,
lib/backs3/restore.rb,
lib/backs3/file_info.rb

Overview

:nodoc:

Defined Under Namespace

Modules: VERSION Classes: Backup, FileInfo, Restore

Instance Method Summary collapse

Instance Method Details

#load_backup_infoObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/backs3/backs3.rb', line 33

def load_backup_info
  @backups ||= begin
    backup_info_file = storage.read('s3backup') || ''
    YAML.load(backup_info_file) || []
  rescue Exception => e
    puts e.to_s
    []
  end
  
  unless @backups.respond_to?(:sort) && @backups.respond_to?(:each) && @backups.respond_to?(:reject!)
    @backups = []
  end
  
  @backups.reject! do |backup|
    !backup.respond_to?(:date)
  end
  
  @backups.sort do |a,b|
    a.date <=> b.date
  end
  
  @backups
end

#loggerObject



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

def logger
  logger_output = @options['logger'] || $stdout
  @logger ||= Logger.new(logger_output)
end

#md5(filename) ⇒ Object



24
25
26
# File 'lib/backs3/backs3.rb', line 24

def md5(filename)
  Digest::MD5.hexdigest(filename)
end

#save_backup_info(info) ⇒ Object



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

def save_backup_info(info)
  storage.store('s3backup', YAML.dump(info))
  logger.info "Backup info has been stored"
end