Class: Automan::Cli::Snapper

Inherits:
Base
  • Object
show all
Defined in:
lib/automan/cli/snapper.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #version

Instance Method Details

#countObject



111
112
113
114
115
116
117
118
119
# File 'lib/automan/cli/snapper.rb', line 111

def count
  if options[:database].nil? && options[:environment].nil?
    puts "Must specify either database or environment"
    help "count"
    exit 1
  end

  Automan::RDS::Snapshot.new(options).count_snapshots
end

#createObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/automan/cli/snapper.rb', line 48

def create
  if options[:database].nil? && options[:environment].nil?
    puts "Must specify either database or environment"
    help "create"
    exit 1
  end

  if options[:prune]
    if options[:type].nil? || options[:max_snapshots].nil?
      puts "Must specify snapshot type and max snapshots to retain when pruning"
      help "create"
      exit 1
    end
  end

  aws_opts = options.dup
  aws_opts[:log_aws] = true
  s = Automan::RDS::Snapshot.new(aws_opts)
  s.prune_snapshots if options[:prune]
  s.create
end

#deleteObject



77
78
79
# File 'lib/automan/cli/snapper.rb', line 77

def delete
  Automan::RDS::Snapshot.new(options).delete
end

#latestObject



91
92
93
94
95
96
97
98
99
# File 'lib/automan/cli/snapper.rb', line 91

def latest
  if options[:database].nil? && options[:environment].nil?
    puts "Must specify either database or environment"
    help "latest"
    exit 1
  end

  Automan::RDS::Snapshot.new(options).latest
end