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

pg_restore: error: input file appears to be a text format dump. Please use psql. #482

Open
roflmaostc opened this issue Apr 23, 2023 · 1 comment

Comments

@roflmaostc
Copy link

Hi,

Since recently, the command python manage.py dbrestore -I file.psql does not work for me anymore.

You got any idea or help how to fix this?

I'm using Linux and psql (PostgreSQL) 15.2 and

django-dbbackup               4.0.2
Django                        3.2.18
Python 3.10.10
(orpheus) ╭─fxw@earth ~/Documents/Orpheus/django/orpheuscc  ‹master*› 
╰─➤  python manage.py dbrestore -I ../orpheuscc_backup/orpheuscc/default-orpheus-2023-04-22-033304.psql                                  [23-04-23 | 1:06:17]
Are you sure you want to continue? [Y/n] Y
Traceback (most recent call last):
  File "/home/fxw/Documents/Orpheus/django/orpheuscc/manage.py", line 21, in <module>
    main()
  File "/home/fxw/Documents/Orpheus/django/orpheuscc/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/dbbackup/management/commands/dbrestore.py", line 68, in handle
    self._restore_backup()
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/dbbackup/management/commands/dbrestore.py", line 118, in _restore_backup
    self.connector.restore_dump(input_file)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/dbbackup/db/base.py", line 105, in restore_dump
    return self._restore_dump(dump)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/dbbackup/db/postgresql.py", line 124, in _restore_dump
    stdout, stderr = self.run_command(cmd, stdin=dump, env=self.restore_env)
  File "/home/fxw/Documents/Orpheus/django/orpheus/lib/python3.10/site-packages/dbbackup/db/base.py", line 171, in run_command
    raise exceptions.CommandConnectorError(
dbbackup.db.exceptions.CommandConnectorError: Error running:  pg_restore --dbname=postgresql://XXXXXX:XXXXX-G-6iXeiJ@localhost/XXXXXX --single-transaction --clean 
pg_restore: error: input file appears to be a text format dump. Please use psql.

CC: @MaxTechCode

@rodleiva
Copy link

rodleiva commented Nov 17, 2023

To complement. I confirm the problem. I have backup files from a system running the following:
Django 3.2.9
django-dbbackup 3.3
backend database: postgres

The dump file generated by dbbackup are compressed text files *.psql.gz

The upgraded system running the following:
Django==4.2.7
django-dbbackup==4.0.2

Without changes in the configuration, the dump files generated by dbbackup are now binary compressed files *.psql.bin.gz
I can import the bin.gz files, but I'm unable to import the text dumps generated with the previous version.

The solution is given in #456, 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",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants