简体   繁体   中英

restore postgreSQL database on Django project

I'm working on an application that runs on Ubuntu 18.04 , it consists of Django App and PostgreSQL server, each on runs in a separate Docker container.
I created a backup for my database, so I can keep it and runs it on a test server for test cases.
Now I'm moving my backup database to another test server, but the problem is when I run:

docker-compose -f production.yml up

both containers of Django & PostgreSQL run fine, the problem is which should I do first to make everything working on the test server, like everything working on the production server? should I restore backup database first then run:

python manage.py migrate

or should I migrate then restore backup database, actually I ran both, and each time after successfully end both I got this error:

ProgrammingError at /accounts/login/

so what should I do to restore backup database?

Anther question:
I tried to ignore the backup database and just run:

python manage.py migrate

and create a database from scratch but I got the same error as before!!! I'm there is something common I'm wrong with, so help me with any information on the theory of backup database, please.

Assuming you're using a pg_dump, you don't need to run migrate.py . The backup file will recreate all the tables and all the data in the tables. Before running psql to restore the data, you need to drop the database and re-create it. After you have created it and restored the file, you can then run a migrate.py whenever you make changes to your models.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM