Module: ForemanMaintain::Cli::BackupCommon

Included in:
OfflineBackupCommand, OnlineBackupCommand
Defined in:
lib/foreman_maintain/cli/backup_command.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
# File 'lib/foreman_maintain/cli/backup_command.rb', line 4

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#backup_dirObject



8
9
10
# File 'lib/foreman_maintain/cli/backup_command.rb', line 8

def backup_dir
  @backup_dir ||= preserve_directory? ? backup_root_dir : backup_subdir
end

#backup_subdirObject



16
17
18
19
# File 'lib/foreman_maintain/cli/backup_command.rb', line 16

def backup_subdir
  name = feature(:instance).product_name.downcase.tr(' ', '-')
  File.join(backup_root_dir, "#{name}-backup-" + timestamp)
end

#perform_backup(strategy, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/foreman_maintain/cli/backup_command.rb', line 21

def perform_backup(strategy, options = {})
  backup_scenario = backup_scenario(options, strategy)
  rescue_scenario = rescue_scenario(options, strategy)
  puts "Starting backup: #{Time.now}"
  run_scenario(backup_scenario, rescue_scenario)
  puts "Done with backup: #{Time.now}"
  final_message
  exit runner.exit_code
end

#timestampObject



12
13
14
# File 'lib/foreman_maintain/cli/backup_command.rb', line 12

def timestamp
  DateTime.now.strftime('%Y-%m-%d-%H-%M-%S')
end