Fix issue #34: delete PostgreSQL database before restoration

This commit is contained in:
Stéphane Klein 2018-01-12 12:15:05 +01:00
parent 52e653dd30
commit 5272729f9a
1 changed files with 1 additions and 1 deletions

View File

@ -165,7 +165,7 @@ If your issue is not here, look through [the existing issues][issues] and eventu
* You can enter the shell of the running Netbox container using `docker-compose exec netbox /bin/bash`. Now you have access to `./manage.py`, e.g. to reset a password. * You can enter the shell of the running Netbox container using `docker-compose exec netbox /bin/bash`. Now you have access to `./manage.py`, e.g. to reset a password.
* To access the database run `docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'` * To access the database run `docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`
* To create a database backup run `docker-compose exec postgres sh -c 'pg_dump -U $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump.sql.gz` * To create a database backup run `docker-compose exec postgres sh -c 'pg_dump -U $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump.sql.gz`
* To restore that database backup run `gunzip -c db_dump.sql.gz | docker exec -i $(docker-compose ps -q postgres) sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`. * To restore that database backup run `docker-compose exec postgres sh -c "su postgres -c 'dropdb $POSTGRES_DB --if-exists; createdb $POSTGRES_DB'"; gunzip -c db_dump.sql.gz | docker exec -i $(docker-compose ps -q postgres) sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`.
### Getting a "Bad Request (400)" ### Getting a "Bad Request (400)"