Skip to content

Commit

Permalink
Merge pull request #75 from trjohnson19/trjohnson19/55-postgres-shoul…
Browse files Browse the repository at this point in the history
…d-not-write-db-to-remote-location

Move `postgres` data dir to `$APPDIR`, add restore comment
  • Loading branch information
trjohnson19 authored May 21, 2024
2 parents 67d1a2c + a516b27 commit d422617
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion backup-scripts/borg-patternfile.example.lst
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ R /home/<USER>/docker
## Postgres ############################
########################################
+ /home/<USER>/docker/appdata/postgres/config
+ /home/<USER>/docker/appdata/postgres/data

# Backed up via pg_dumpall
! /home/<USER>/docker/appdata/postgres/data

- /home/<USER>/docker/appdata/postgres/**

Expand Down
10 changes: 8 additions & 2 deletions docker-compose-t2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,17 @@ services:
## CREATE USER <username> WITH PASSWORD '<password>';
## CREATE DATABASE <dbname> OWNER <username>;
## GRANT ALL PRIVILEGES ON DATABASE <dbname> TO <username>;
##
## Steps for restoring from a backup:
## 1. Place the output of pg_dump in a convenient location, e.g., "${DOCKERDIR}/backup/postgres_dump.sql"
## 2. Start `postgres` with a clean data directory
## 3. Run the following command to recreate the database as specified in the postgres_dump.sql file
## sudo docker exec -i --user=postgres postgres psql --dbname=postgres < ./backup/postgres_dump.sql
postgres:
<<: *common-keys-core
container_name: postgres
image: postgres:16
# user: "${PUID}:${PGID}"
user: "${PUID}:${PGID}"
networks:
t2_proxy:
ipv4_address: $POSTGRES_IPV4
Expand All @@ -816,7 +822,7 @@ services:
timeout: 5s
volumes:
- $APPDIR/postgres/config:/config
- $DATADIR/postgres/data:/var/lib/postgresql/data
- $APPDIR/postgres/data:/var/lib/postgresql/data
environment:
<<: *default-tz-puid-pgid
POSTGRES_USER_FILE: /run/secrets/postgres_user
Expand Down

0 comments on commit d422617

Please sign in to comment.