Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgresql schema support #424

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
Update postgresql.py
twkrol authored Jan 24, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit b9464d2817ebe01ef8588600f28389c3828bcc61
8 changes: 8 additions & 0 deletions dbbackup/db/postgresql.py
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@ def _create_dump(self):
cmd += ' --exclude-table-data={}'.format(table)
if self.drop:
cmd += ' --clean'
if self.schema:
cmd += ' -n {}'.format(self.schema)

cmd = '{} {} {}'.format(self.dump_prefix, cmd, self.dump_suffix)
stdout, stderr = self.run_command(cmd, env=self.dump_env)
@@ -56,6 +58,8 @@ def _restore_dump(self, dump):

# without this, psql terminates with an exit value of 0 regardless of errors
cmd += ' --set ON_ERROR_STOP=on'
if self.schema:
cmd += ' -n {}'.format(self.schema)
if self.single_transaction:
cmd += ' --single-transaction'
cmd += ' {}'.format(self.settings['NAME'])
@@ -102,6 +106,8 @@ class PgDumpBinaryConnector(PgDumpConnector):
def _create_dump(self):
cmd = '{} '.format(self.dump_cmd)
cmd = cmd + create_postgres_uri(self)
if self.schema:
cmd += ' -n {}'.format(self.schema)

cmd += ' --format=custom'
for table in self.exclude:
@@ -114,6 +120,8 @@ def _restore_dump(self, dump):
dbname = create_postgres_uri(self)
cmd = '{} {}'.format(self.restore_cmd, dbname)

if self.schema:
cmd += ' -n {}'.format(self.schema)
if self.single_transaction:
cmd += ' --single-transaction'
if self.drop: