Class: Backup::Repositories

Inherits:
Task
  • Object
show all
Extended by:
Gitlab::Utils::Override
Defined in:
lib/backup/repositories.rb

Overview

Backup and restores repositories by querying the database

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods inherited from Task

#post_restore_warning, #pre_restore_warning

Constructor Details

#initialize(progress, strategy:, storages: [], paths: [], skip_paths: []) ⇒ Repositories

Returns a new instance of Repositories.

Parameters:

  • progress (IO)

    IO interface to output progress

  • :strategy (Object)

    Fetches backups from gitaly

  • :storages (Array<String>)

    Filter by specified storage names. Empty means all storages.

  • :paths (Array<String>)

    Filter by specified project paths. Empty means all projects, groups, and snippets.

  • :skip_paths (Array<String>)

    Skip specified project paths. Empty means all projects, groups, and snippets.



15
16
17
18
19
20
21
22
# File 'lib/backup/repositories.rb', line 15

def initialize(progress, strategy:, storages: [], paths: [], skip_paths: [])
  super(progress)

  @strategy = strategy
  @storages = storages
  @paths = paths
  @skip_paths = skip_paths
end

Instance Method Details

#dump(destination_path, backup_id) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/backup/repositories.rb', line 25

def dump(destination_path, backup_id)
  strategy.start(:create, destination_path, backup_id: backup_id)
  enqueue_consecutive

ensure
  strategy.finish!
end

#restore(destination_path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/backup/repositories.rb', line 34

def restore(destination_path)
  strategy.start(:restore, destination_path, remove_all_repositories: remove_all_repositories)
  enqueue_consecutive

ensure
  strategy.finish!

  cleanup_snippets_without_repositories
  restore_object_pools
end