Vincent Dapiton
Vincent Dapiton

Reputation: 587

Django: dbbackup displays pg_dump: error: too many command-line arguments

I've installed the django-dbbackup package and from what the Documentation tells, i need to run python manage.py dbbackup

but it generated error pg_dump: error: too many command-line arguments

from what i have seen in the logs

dbbackup.db.exceptions.CommandConnectorError: Error running:  pg_dump database_name --host=127.0.0.1 --port=5432 --username=postgres --no-password --clean

From what i have known, the correct command for pg_dump is to include the database name in the last part but the dbbackup include the database name first.

Anyone know the fix for the Django-dbbackup?

Upvotes: 1

Views: 1391

Answers (2)

Gurleen Kaur
Gurleen Kaur

Reputation: 11

I had the same error. What I did was

  1. Made sure pg_dump was in the environment variable in my system.
  2. pip uninstall dbbackup
  3. pip install django-dbbackup --upgrade

And it worked!

Upvotes: 1

Tai Zhang
Tai Zhang

Reputation: 379

I have same issue with you, this is my env

  • Window 10
  • postgres10
  • django 2.2.9
  • django-dbbackup 3.2.0

I can manual run successfully like below, add "--dbname" parm name.

pg_dump --dbname=database_name --host=127.0.0.1 --port=5432 --username=postgres --no-password --clean

I don't know how to override the command by create a new method, so I changed the source code in dbbackup package directly, it works.

file "\Lib\site-packages\dbbackup\db\postgresql.py"

from:

    cmd = '{} --dbname={}'.format(self.dump_cmd, self.settings['NAME'])

to:

    cmd = '{} {}'.format(self.dump_cmd, self.settings['NAME'])

Upvotes: 0

Related Questions