Class: KamalBackup::Databases::Postgres
- Inherits:
-
Base
- Object
- Base
- KamalBackup::Databases::Postgres
show all
- Defined in:
- lib/kamal_backup/databases/postgres.rb
Constant Summary
collapse
- SOURCE_ENV_KEYS =
%w[
PGHOST
PGPORT
PGUSER
PGPASSWORD
PGDATABASE
PGSSLMODE
PGSSLROOTCERT
PGSSLCERT
PGSSLKEY
PGCONNECT_TIMEOUT
PGSERVICE
PGPASSFILE
].freeze
Instance Attribute Summary
Attributes inherited from Base
#config, #redactor
Instance Method Summary
collapse
Methods inherited from Base
#backup, #backup_tags, build, #database_filename, #initialize, #restore_to_current, #restore_to_scratch
Instance Method Details
#adapter_name ⇒ Object
24
25
26
|
# File 'lib/kamal_backup/databases/postgres.rb', line 24
def adapter_name
'postgres'
end
|
#current_restore_command ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/kamal_backup/databases/postgres.rb', line 37
def current_restore_command
connection = current_connection
database = connection.fetch('PGDATABASE')
argv = %w[pg_restore --clean --if-exists --no-owner --no-privileges --dbname]
argv << database
CommandSpec.new(argv: argv, env: connection)
end
|
#current_target_identifier ⇒ Object
54
55
56
|
# File 'lib/kamal_backup/databases/postgres.rb', line 54
def current_target_identifier
value('DATABASE_URL') || value('PGDATABASE')
end
|
#dump_command ⇒ Object
32
33
34
35
|
# File 'lib/kamal_backup/databases/postgres.rb', line 32
def dump_command
argv = %w[pg_dump --format=custom --no-owner --no-privileges]
CommandSpec.new(argv: argv, env: current_connection)
end
|
#dump_extension ⇒ Object
28
29
30
|
# File 'lib/kamal_backup/databases/postgres.rb', line 28
def dump_extension
'pgdump'
end
|
#scratch_restore_command(target) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/kamal_backup/databases/postgres.rb', line 46
def scratch_restore_command(target)
connection = current_connection.merge('PGDATABASE' => target)
argv = %w[pg_restore --clean --if-exists --no-owner --no-privileges --dbname]
argv << target
CommandSpec.new(argv: argv, env: connection)
end
|
#scratch_target_identifier(target) ⇒ Object
58
59
60
|
# File 'lib/kamal_backup/databases/postgres.rb', line 58
def scratch_target_identifier(target)
[current_connection['PGHOST'], target].compact.join('/')
end
|