-
run the db server and pgAdmin instances.
make up
-
copy the database .tar file to docker volume.
docker cp dvdrental.tar project-phanpy_db_1:/var/lib/postgresql/data
docker exec project-phanpy_db_1 ls /var/lib/postgresql/data
-
restore databse from .tar file.
docker exec project-phanpy_db_1 pg_restore -c -U admin -d dvdrental -v '/var/lib/postgresql/data/dvdrental.tar'
-
go to
localhost:8080
and use pgAdmin to manage db.
-
install
PostgreSQL
extension. -
connect to db server.
-
send query.
-
with the old PostgreSQL service running, make a backup of the current data
docker exec project-phanpy_db_1 pg_dumpall -U admin > dump.sql
-
stop the running container and delete mapped volume
docker volume rm project-phanpy_db-data
-
update docker-compose configuration, start the services and restore from backup
docker exec project-phanpy_db_1 psql -U admin -d dvdrental -f /var/lib/postgresql/data/dump.sql