How to backup Postgresql
Artem
Posted on April 25, 2021
If your Postgres in docker container use pg_dumpall
to backup:
docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
and then restore it:
cat dump_24-04-2021_20_50_17.sql | docker exec -i some-postgres psql -U postgres
If you want to play with the current command we can run a new docker container with postgres, create table, and check how a command is working.
Start a container:
docker run --name some-postgres -e POSTGRES_PASSWORD=pass -d postgres
Go inside the container:
docker exec -it some-postgres bash
Start psql console:
psql -U postgres
Create table:
CREATE TABLE first_table (column1 int);
And then you can do anything you want :)
💖 💪 🙅 🚩
Artem
Posted on April 25, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.