diff --git a/.vitepress/config.mts b/.vitepress/config.mts index d5598dd..e07ac5b 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -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/', diff --git a/docs/index.md b/docs/index.md index 3cafd78..0d529bf 100644 --- a/docs/index.md +++ b/docs/index.md @@ -46,6 +46,10 @@ hero: text: Nuxt link: /nuxt/ + - theme: alt + text: Postgres + link: /postgres/ + - theme: alt text: PowerShell link: /powershell/ diff --git a/docs/postgres/dump-and-restore.md b/docs/postgres/dump-and-restore.md new file mode 100644 index 0000000..332c056 --- /dev/null +++ b/docs/postgres/dump-and-restore.md @@ -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 +``` \ No newline at end of file diff --git a/docs/postgres/index.md b/docs/postgres/index.md new file mode 100644 index 0000000..a1af707 --- /dev/null +++ b/docs/postgres/index.md @@ -0,0 +1,3 @@ +# Postgres Snippets and Musings + +#### [Dump and Restore](./dump-and-restore.md) \ No newline at end of file