summaryrefslogtreecommitdiff
path: root/lib/backup.rb
blob: 95b595d885a866caf6d3118bdd14a9f9c186669a (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
# frozen_string_literal: true

module Backup
  Error = Class.new(StandardError)

  class FileBackupError < Backup::Error
    attr_reader :app_files_dir, :backup_tarball

    def initialize(app_files_dir, backup_tarball)
      @app_files_dir = app_files_dir
      @backup_tarball = backup_tarball
    end

    def message
      "Failed to create compressed file '#{backup_tarball}' when trying to backup the following paths: '#{app_files_dir}'"
    end
  end

  class DatabaseBackupError < Backup::Error
    attr_reader :config, :db_file_name

    def initialize(config, db_file_name)
      @config = config
      @db_file_name = db_file_name
    end

    def message
      "Failed to create compressed file '#{db_file_name}' when trying to backup the main database:\n - host: '#{config[:host]}'\n - port: '#{config[:port]}'\n - database: '#{config[:database]}'"
    end
  end
end