Class: Crashbreak::PredefinedSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/crashbreak/predefined_settings.rb

Class Method Summary collapse

Class Method Details

.dump_file_locationObject



4
5
6
# File 'lib/crashbreak/predefined_settings.rb', line 4

def dump_file_location
  "#{Crashbreak.project_root}/tmp/:error_id:/db.dump"
end

.dump_folder_locationObject



8
9
10
# File 'lib/crashbreak/predefined_settings.rb', line 8

def dump_folder_location
  "#{Crashbreak.project_root}/tmp/:error_id:/db_dump"
end

.heroku_postgresql(db_name, app_name) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/crashbreak/predefined_settings.rb', line 21

def heroku_postgresql(db_name, app_name)
  setup_restorer_for_postgresql

  config.dumper_options.reverse_merge!(
      dump_location: dump_file_location,
      dump_command: "/app/vendor/heroku-toolbelt/bin/heroku pg:backups capture #{db_name} -a #{app_name} &&" +
          "curl -o #{dump_file_location} `/app/vendor/heroku-toolbelt/bin/heroku pg:backups public-url --app #{app_name}`"
  )
end

.mongodb(db_name) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/crashbreak/predefined_settings.rb', line 31

def mongodb(db_name)
  setup_restorer_for_mongo(db_name)

  config.dumper_options.reverse_merge!(
      dump_location: dump_file_location,
      dump_command: "mongodump --db #{db_name} --out #{dump_folder_location} &&
                     tar -cvf #{dump_file_location} -C #{dump_folder_location} . &&
                     rm -rf #{dump_folder_location}"
  )
end

.postgresql(db_name) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/crashbreak/predefined_settings.rb', line 12

def postgresql(db_name)
  setup_restorer_for_postgresql

  config.dumper_options.reverse_merge!(
      dump_location: dump_file_location,
      dump_command: "pg_dump -Fc #{db_name} > #{dump_file_location}"
  )
end