Class: RosettAi::Thor::Tasks::Backup

Inherits:
Thor
  • Object
show all
Includes:
Formatting
Defined in:
lib/rosett_ai/thor/tasks/backup.rb

Overview

Thor task for backing up rosett-ai directory structure and assets

Constant Summary

Constants included from Formatting

Formatting::SIZE_UNITS

Instance Method Summary collapse

Methods included from Formatting

#format_duration, #format_size

Instance Method Details

#createvoid

This method returns an undefined value.

Create the resource.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rosett_ai/thor/tasks/backup.rb', line 72

def create
  validate_options!
  compressor = resolve_compressor
  check_compression_available!(compressor)
  destination = resolve_destination(compressor)
  files = collect_all_files

  if files.empty?
    puts Rainbow(t('no_files')).yellow
    return
  end

  result = create_archive(files, compressor, destination)
  print_summary(result)
end

#restore(archive_path) ⇒ void

This method returns an undefined value.

Restore configuration from a backup archive.

Parameters:

  • archive_path (Object)

    the archive path



114
115
116
117
118
119
# File 'lib/rosett_ai/thor/tasks/backup.rb', line 114

def restore(archive_path)
  validate_archive!(archive_path)
  entries = extract_entries(archive_path)
  restored = restore_entries(entries)
  print_restore_summary(archive_path, restored)
end