mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-10 08:30:50 +03:00
* Update generated project's .gitignore * Post-gen gitignore .env/ and .env * Fix linesep between gitignored entries * Persist `.env/**/*` files into cookiecutter-django's VCS * Rename .env/ to .envs/ * Reference the newly created .envs/**/.* files in local.yml * Reference the newly created .envs/**/.* files in production.yml * Delete .env.example * Refactor post-gen-project.py Closes #1299. * Implement production-dotenv-files-to-dotenv-file merge script * Create shared PyCharm Run Configuration for the automation script * Randomize POSTGRES_PASSWORD in ./envs/(.local|.production)/.postgres * Default POSTGRES_PASSWORD and POSTGRES_USER to random values * Fix jinja linebreaks in local.yml * Spaces in production.yml * Fix post-merge leftovers & set DJANGO_ADMIN_URL automatically * Prettify here and there * Fix FileNotFoundError * Leave a TODO in post_gen_hook.py * Introduce keep_local_envs_in_vcs option * Remove envs when not opted for * Inline pre_gen_project.py if-condition * Get rid of PROJECT_DIR_PATH in post_gen_project.py * Clean up the docs * Match copyright notices * Document envs ins and outs
41 lines
1.0 KiB
ReStructuredText
41 lines
1.0 KiB
ReStructuredText
============================
|
|
Database Backups with Docker
|
|
============================
|
|
|
|
The database has to be running to create/restore a backup. These examples show local examples. If you want to use it on a remote server, use ``-f production.yml`` instead.
|
|
|
|
Running Backups
|
|
================
|
|
|
|
Run the app with `docker-compose -f local.yml up`.
|
|
|
|
To create a backup, run::
|
|
|
|
docker-compose -f local.yml run --rm postgres backup
|
|
|
|
|
|
To list backups, run::
|
|
|
|
docker-compose -f local.yml run --rm postgres list-backups
|
|
|
|
|
|
To restore a backup, run::
|
|
|
|
docker-compose -f local.yml run --rm postgres restore filename.sql
|
|
|
|
Where <containerId> is the ID of the Postgres container. To get it, run::
|
|
|
|
docker ps
|
|
|
|
To copy the files from the running Postgres container to the host system::
|
|
|
|
docker cp <containerId>:/backups /host/path/target
|
|
|
|
Restoring From Backups
|
|
======================
|
|
|
|
To restore the production database to a local PostgreSQL database::
|
|
|
|
createdb NAME_OF_DATABASE
|
|
psql NAME_OF_DATABASE < NAME_OF_BACKUP_FILE
|