I have a cookiecutter django template project working fine with a local postgres database.
(https://cookiecutter-django.readthedocs.io/en/latest/)
I’ve copied the git repository and recreated the docker images on a new host to run in production, but I would like to export/copy my data as well.
What’s the recommended way to move the data over from the postgres docker instance ?
Thanks
2
Answers
Ok, figured it out.
I re-created the docker images (cookiecutter easily re-creates them with docker compose script after I copied the source over via git, but can also manually re-create or export) and then dump directly from postgres. In the case of cookiecutter in general, can just:
and then copy over from the container to host:
On the new host, copy the file back and:
For non-docker setups, you can just run "postgres backup" directly
You can generate a
JSON
output of all database data using thedumpdata
command in Django. Transfer theJSON
file to your host, and then reimport the data into the database. Refer to this article for a comprehensive guide on reading detailed instructions on the entire process.https://cpske.github.io/ISP/django/data-import-export