Class: S3snapshot::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/s3snapshot/cli.rb

Instance Method Summary collapse

Instance Method Details

#backupObject

Uploads the directory to the s3 bucket with a prefix



21
22
23
24
25
26
27
# File 'lib/s3snapshot/cli.rb', line 21

def backup
  directory = options[:directory]
  puts "You are uploading directory #{directory}"
  
  s3upload = DirUpload.new(options[:awsid], options[:awskey], options[:bucket], options[:prefix], directory, options[:tmpdir] )
  s3upload.upload
end

#cleanObject



127
128
129
130
131
132
# File 'lib/s3snapshot/cli.rb', line 127

def clean
  manager = BackupManager.new(options[:awsid], options[:awskey], options[:bucket])
  
  manager.clean(options[:prefix])
  
end

#prefixesObject



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/s3snapshot/cli.rb', line 78

def prefixes
  manager = BackupManager.new(options[:awsid], options[:awskey], options[:bucket])
  
  puts "Found the following prefixes\n\n"
  
  manager.prefixes.each do |prefix|
    puts prefix[0..-2]
  end
  
  puts "\n"
end

#restoreObject



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

def restore
  time = Time.parse(options[:time])
  download = DirDownload.new(options[:awsid], options[:awskey], options[:bucket], options[:prefix], time, options[:dest])
  download.download
end

#restorelatestObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/s3snapshot/cli.rb', line 57

def restorelatest
  
  manager = BackupManager.new(options[:awsid], options[:awskey], options[:bucket])
  latest_complete = manager.latest(options[:prefix])
  
  if latest_complete.nil?
    puts "Cannot find a complete snapshot with prefix #{options[:prefix]}"
    exit 1
  end
        
  download = DirDownload.new(options[:awsid], options[:awskey], options[:bucket], options[:prefix], latest_complete, options[:dest])
  download.download
end

#rollObject



147
148
149
150
151
152
# File 'lib/s3snapshot/cli.rb', line 147

def roll
  manager = BackupManager.new(options[:awsid], options[:awskey], options[:bucket])
  
  manager.roll(options[:prefix], options[:numdays], options[:numweeks], options[:dayofweek])
  
end

#snapshotsObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/s3snapshot/cli.rb', line 100

def snapshots
  manager = BackupManager.new(options[:awsid], options[:awskey], options[:bucket])
  
  snap_map = manager.snapshots(options[:prefix])
  
  puts "Found the following timestamps from prefix #{options[:prefix]}\n\n"
  
  snap_map.each do |key, value|
    result = value ? "complete" : "unknown"
    
    puts "Time: #{key.iso8601}, Status: #{result}"
  end
  
  puts "\n"
  
end