You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make more pg_dump/pg_restore flags available to facilitate operations across databases.
Problem definition
When running dbbackup on one server and dbrestore on another server, especially when a separate database (i.e. migration) is used as well doesn't work. The default pg_dump/pg_restore settings include many operations that are database specific options and not relevant to django, for instance:
The table owner will likely be different
The --no-owner flag solves this problem
The database can have ACLs, roles, grants which are not related to django but to the operations of that database
The --no-privileges flag solves this problem
Without these flags the errors can be cryptic and hard to understand when a command on a random table or fails.
Temporary solution
I was able to solve the first 2 points above using the suggestion from #213 (comment)
Using the following in settings.py:
DBBACKUP_CONNECTOR_MAPPING = {
'django.db.backends.postgresql': 'dbbackup.db.postgresql.PgDumpBinaryConnector',
}
DBBACKUP_CONNECTORS = {
'default': {
# 'dump_suffix': '--no-owner', # Does not work because it comes after command
'dump_cmd': 'pg_dump --no-owner --no-privileges',
'restore_cmd': 'pg_restore --no-owner --no-privileges',
}
}
Allowed me to export and import with out running into owner or ACL issues.
Possible improvements
One improvements would be to make these flags available or a way to insert arguments into the dump and restore commands (as mentioned in the issue link the suffix happens too late) would make it cleaner and improve the documentation.
Another improvement might be to consider the no owner and perhaps also the no privileges as default options, it's not ideal because it might be a breaking changes in some cases but from my understanding they're not critical or needed for a standard django installation so they might be safer defaults (especially if there's a documented way to turn them off).
The text was updated successfully, but these errors were encountered:
Feature Request
Make more pg_dump/pg_restore flags available to facilitate operations across databases.
Problem definition
When running dbbackup on one server and dbrestore on another server, especially when a separate database (i.e. migration) is used as well doesn't work. The default pg_dump/pg_restore settings include many operations that are database specific options and not relevant to django, for instance:
--no-owner
flag solves this problem--no-privileges
flag solves this problemWithout these flags the errors can be cryptic and hard to understand when a command on a random table or fails.
Temporary solution
I was able to solve the first 2 points above using the suggestion from #213 (comment)
Using the following in
settings.py
:Allowed me to export and import with out running into owner or ACL issues.
Possible improvements
One improvements would be to make these flags available or a way to insert arguments into the dump and restore commands (as mentioned in the issue link the suffix happens too late) would make it cleaner and improve the documentation.
Another improvement might be to consider the no owner and perhaps also the no privileges as default options, it's not ideal because it might be a breaking changes in some cases but from my understanding they're not critical or needed for a standard django installation so they might be safer defaults (especially if there's a documented way to turn them off).
The text was updated successfully, but these errors were encountered: