postgres commands
This commit is contained in:
21
docs/postgres/dump-and-restore.md
Normal file
21
docs/postgres/dump-and-restore.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Dump and Restore
|
||||
|
||||
Handy commands for dumping and restoring Postgres databases.
|
||||
|
||||
:::info
|
||||
Most of these commands are run using Docker as then we don't need to have Postgres installed locally.
|
||||
|
||||
If a different version of Postgres is needed, just change the version number in the Docker image tag.
|
||||
:::
|
||||
|
||||
## Dumping a Database
|
||||
|
||||
```bash
|
||||
docker run --network host --rm -v .:/tmp -e PGPASSWORD=mysecretpassword postgres:16 pg_dump -h localhost -U myuser -d mydb > /tmp/dump.sql
|
||||
```
|
||||
|
||||
## Restoring a Database
|
||||
|
||||
```bash
|
||||
docker run --network host --rm -v .:/tmp -e PGPASSWORD=mysecretpassword postgres:16 psql -h localhost -U myuser -d mydb < /tmp/dump.sql
|
||||
```
|
Reference in New Issue
Block a user