Skip to content

Commit

Permalink
docs: add info for restoring from db backup
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 10, 2023
1 parent d56bde0 commit 724426d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/dev/Backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ Running the database in Docker means postgres does not need to be installed on y
2. Start an instance of Postgres (with Postgis):

```bash
docker run -d --name fmtm_db -e POSTGRES_PASSWORD=xxxx -p 5432:5432 postgis/postgis:15-3.3
GIT_BRANCH=development

docker run -d --name fmtm-db-${GIT_BRANCH} -e POSTGRES_PASSWORD=xxxx -p 5432:5432 postgis/postgis:15-3.3
```

The database should be accessible at localhost:5432.
Expand Down
6 changes: 4 additions & 2 deletions docs/dev/Database-Tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ psql -d fmtm -U fmtm -h localhost

### Option 2

Access a PostgreSQL shell inside the fmtm_db container:
Access a PostgreSQL shell inside the fmtm-db container:

```bash
docker exec -it fmtm_db psql -U fmtm fmtm
GIT_BRANCH=development

docker exec -it fmtm-db-${GIT_BRANCH} psql -U fmtm fmtm
```

And then connect to the database using this command:
Expand Down
13 changes: 12 additions & 1 deletion docs/dev/Production.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,19 @@ This will map port 5432 on the remote machine to port 5430 on your local machine
## Manual Database Backups

```bash
GIT_BRANCH=development
backup_filename="fmtm-db-backup-$(date +'%Y-%m-%d').sql.gz"
echo $backup_filename

docker exec -i -e PGPASSWORD=PASSWORD_HERE fmtm_db pg_dump --verbose --format c -U fmtm fmtm | gzip -9 > "$backup_filename"
docker exec -i -e PGPASSWORD=PASSWORD_HERE fmtm-db-${GIT_BRANCH} pg_dump --verbose --format c -U fmtm fmtm | gzip -9 > "$backup_filename"
```

## Manual Database Restores

```bash
# On a different machine (else change the container name)
GIT_BRANCH=development
backup_filename=fmtm-db-backup-XXXX-XX-XX-sql.gz

cat "$backup_filename" | gunzip | docker exec -i -e PGPASSWORD=NEW_PASSWORD_HERE fmtm-db-${GIT_BRANCH} pg_restore --verbose -U fmtm -d fmtm
```

0 comments on commit 724426d

Please sign in to comment.