Creates a demo postgresql database in a docker container through a docker-compose file.
Note: You must have docker installed on your local machine. Follow steps here;
Get Docker - https://docs.docker.com/get-docker/
Note: Must have admin rights when running command prompt and you must be in the directory where the docker-compose.yml is located.
This will run the docker-compose.yml file. More on docker compose can be found at https://docs.docker.com/compose/.
$ docker-compose up -d
When you have finished with the container, you can remove it by runnign the following command
$ docker-compose down
Here is the command need to run to back up the PostgreSQL database.
$ docker exec -u <your_postgres_user> <postgres_container_name> pg_dump -Fc <database_name_here> > db.dump
Example
$ docker exec -u postgres motogp-postgres-container pg_dump -Fc motogp_db > /Docker/db_backups/motogp_db_backup.sql
You will need to drop the existing database first, and then restore it.
$ docker exec lcs-db-container psql -U postgres -d postgres -c "DROP DATABASE loyalty_db WITH (FORCE);"
Restore database from back up.
$ docker exec -i -u postgres motogp-postgres-container pg_restore -C -d postgres < /Docker/db_backups/motogp_db_backup.sql