postgres commands

This commit is contained in:
2025-10-15 13:16:21 +11:00
parent a19c3bcff4
commit 0948d3e768
4 changed files with 36 additions and 0 deletions

View File

@@ -119,6 +119,14 @@ export default defineConfig({
{ text: 'Custom Fetch', link: '/nuxt/custom-fetch' },
]
},
{
text: 'Postgres',
link: '/postgres/',
collapsed: true,
items: [
{ text: 'Dump and Restore', link: '/postgres/dump-and-restore' },
]
},
{
text: 'PowerShell',
link: '/powershell/',

View File

@@ -46,6 +46,10 @@ hero:
text: Nuxt
link: /nuxt/
- theme: alt
text: Postgres
link: /postgres/
- theme: alt
text: PowerShell
link: /powershell/

View 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
```

3
docs/postgres/index.md Normal file
View File

@@ -0,0 +1,3 @@
# Postgres Snippets and Musings
#### [Dump and Restore](./dump-and-restore.md)