Class: Backup::Targets::Repositories

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

Overview

Backup and restores repositories by querying the database

Instance Attribute Summary

Attributes inherited from Target

#options, #progress

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

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

Constructor Details

#initialize(progress, strategy:, options:, 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.



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

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

  @strategy = strategy
  @storages = storages
  @paths = paths
  @skip_paths = skip_paths
  @logger = Gitlab::BackupLogger.new(progress)
end

Instance Method Details

#asynchronous?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/backup/targets/repositories.rb', line 56

def asynchronous?
  false
end

#dump(destination_path, backup_id) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/backup/targets/repositories.rb', line 28

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

ensure
  strategy.finish!
end

#restore(destination_path, backup_id) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/backup/targets/repositories.rb', line 38

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

ensure
  begin
    strategy.finish!

  rescue Error => e
    logger.error(e.message)
  end

  restore_object_pools
end