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



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

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

#cleanObject



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

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

#prefixesObject



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

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



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

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



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

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



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

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

#snapshotsObject



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

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