summaryrefslogtreecommitdiff
path: root/lib/backup/task.rb
blob: 15cd2aa64d325dcfccc23c8b5d49f3a7a85c71a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

module Backup
  class Task
    def initialize(progress)
      @progress = progress
    end

    # human readable task name used for logging
    def human_name
      raise NotImplementedError
    end

    # dump task backup to `path`
    def dump(path)
      raise NotImplementedError
    end

    # restore task backup from `path`
    def restore(path)
      raise NotImplementedError
    end

    # a string returned here will be displayed to the user before calling #restore
    def pre_restore_warning
    end

    # a string returned here will be displayed to the user after calling #restore
    def post_restore_warning
    end

    # returns `true` when the task should be used
    def enabled
      true
    end

    private

    attr_reader :progress

    def puts_time(msg)
      progress.puts "#{Time.zone.now} -- #{msg}"
      Gitlab::BackupLogger.info(message: "#{Rainbow.uncolor(msg)}")
    end
  end
end