django-dbbackup: Error: constraint does not exist when restoring a backup on a fresh db
- Backed up the database
- Restored the database from the backup
=> Works fine ✅
- Back up the database
- Wipe out the database
- Do the initial django migrate
- Restore the same backup as in the previous case
=> I get the following error ❌
ERROR: constraint "socialaccount_socialapp_site_site_id_2579dee5_fk_django_site_id" of relation "socialaccount_socialapp_sites" does not exist
I guess the issue comes from constraint name not being constant (2579dee5
par above).
Why not use IF NOT EXIST
(https://www.postgresql.org/docs/9.0/static/sql-altertable.html) ?
Or simply wipe out the whole database before importing and remove all the DROP commands?
I guess I miss some historical data (reasons behind decisions), but for now I have a hard time figuring how to restore this dump without manual edit of the relevant lines.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 4
- Comments: 33 (7 by maintainers)
All settings specified above doesn’t work for my installation, so I suppose the built-in dbrestore doesn’t work at all for postgres. (Django==1.11.9, django-dbbackup==3.2.0)
But I was able to restore database by psql directly, actually it’s not so hard.
Media restore works ok, so I’m satisfied 😃
still relevant after 3 years…
I solved my issue by removing all the DROP lines, and replacing
DROP SCHEMA public
bybut being able to load dumps in this case would be super cool 😄
Solved this by adding to settings.py:
@ZuluPro I’m kind of confused here, how do I use the new connector? Doesn’t the pip install take everything needed from your branch?
For now, the manual steps I take to restore a dump from another host:
That’s all folks.
Still relevant for
Django 3.2
and Python 3.10Unfortunetly
'dbbackup.db.postgresql.PgDumpBinaryConnector'
did not make any difference.The problem with
ImportError: No module named postgres
Is due to a typo in the connector settings…'CONNECTOR': 'dbbackup.db.postgres.PgDumpBinaryConnector',
should be:'CONNECTOR': 'dbbackup.db.postgresql.PgDumpBinaryConnector',
@mikeschaekermann
@thimma11 you should just install dbbackup==3.2.0 and then set the connector settings as above, then dbbackup/dbrestore should work.