Method: UBSafe::Commands::Backup#backup

Defined in:
lib/ubsafe/ubsafe_commands/ubsafe_command_backup.rb

#backupInteger

Perform backup

Returns:

  • (Integer)

    Exit code 0 success, 1 otherwise



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ubsafe/ubsafe_commands/ubsafe_command_backup.rb', line 53

def backup
  # Create backup file in source tree
  # Rotate destination files
  # Copy to destination
  # Remove from source tree
  backup_steps = [
    :before_rotate_destination_files, :rotate_destination_files, :after_rotate_destination_files,
    :before_source_backup,:create_source_backup,:after_source_backup,
    :before_copy_backup, :copy_backup, :after_copy_backup,
    :before_clean_source, :clean_source, :after_clean_source
    ]
  backup_steps.each do |backup_step|
    status = self.send(backup_step)
    if status == :failure
      @log.error("Backup #{@backup_name} backup step #{backup_step.to_s} failed.")
      email_notify(:failure,backup_step)
      return 1
    end
  end
  @log.info("Backup  #{@backup_name} succeeded")
  email_notify(:success,nil)
  return 0
end