django-dbbackup icon indicating copy to clipboard operation
django-dbbackup copied to clipboard

How to get a RAW SQL file using postgresql ?

Open pulse-mind opened this issue 3 years ago • 1 comments

Hi,

I am doing a postgresql backup on linux and I get a binary file. To restore it we need to use pg_restore. I'd like to have a RAW SQL file where I can run a regular psql command. How to do that ?

In the documentation it is written :

Postgres uses by default dbbackup.db.postgresql.PgDumpConnector, but we advise you to use dbbackup.db.postgresql.PgDumpBinaryConnector. The first one uses pg_dump and pqsl for its job, creating RAW SQL files.

The second uses pg_restore with binary dump files.

They can also use psql for launching administration command.

In the documentation it is written :

dbbackup.db.postgresql.PgDumpConnector for django.db.backends.postgresql

My database configuration is DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql',...

May be the documentation should be updated to say that

dbbackup.db.postgresql.PgDumpBinaryConnector for django.db.backends.postgresql

Which is probably the right thing: https://github.com/jazzband/django-dbbackup/blob/master/dbbackup/db/base.py

Or ....?

Should I add

DBBACKUP_CONNECTOR_MAPPING = {
    'django.db.backends.postgresql': 'dbbackup.db.postgresql.PgDumpConnector',
}

pulse-mind avatar Jul 31 '22 14:07 pulse-mind

You need to set this configuration in settings.py to override the default config of dbbackup :

DBBACKUP_CONNECTOR_MAPPING = {
    "django.db.backends.postgresql": "dbbackup.db.postgresql.PgDumpConnector",
}

gschurck avatar Oct 15 '23 16:10 gschurck