Skip to content

Commit 8c2a77a

Browse files
committed
Update backup script: generate private table definitions
Previously the public dump missed the definitions, while the private dump only contained the data. We need a 3rd dump that contains the private definitions, in the public directory so that our db dump is actually usable.
1 parent 619b3c2 commit 8c2a77a

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Useful commands:
2424
* Migrations/seeds: `docker compose -f docker-compose.dev.yml exec web bin/rails db:prepare`
2525
* Tests: `docker compose -f docker-compose.dev.yml exec web bundle exec rspec`
2626
* Import a public DB dump: `make db-import DUMP=/path/to/public-YYYY-MM.sql.gz`
27+
* If you need private table definitions too, apply `private-schema-YYYY-MM.sql.gz` after the import:
28+
`gzip -cd /path/to/private-schema-YYYY-MM.sql.gz | docker compose -f docker-compose.dev.yml exec -T db psql`
2729

2830
Makefile shortcuts:
2931
* `make dev` / `make dev-detach` / `make down`

deploy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Access:
9898
## Backups (monthly SQL dumps)
9999
The database dumps are split into public and private data, written to a Docker volume mounted at `/dumps` inside the Postgres container. Each month overwrites the same two files:
100100
- `public/public-YYYY-MM.sql.gz` (full schema + data, excluding private tables)
101+
- `public/private-schema-YYYY-MM.sql.gz` (schema-only for private tables)
101102
- `private/private-YYYY-MM.sql.gz` (data-only for private tables)
102103

103104
The table list lives in `deploy/backup/private_tables.txt` and is used for both dumps.

deploy/backup/run_monthly_dumps.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ docker compose -f docker-compose.yml exec -T db bash -lc \
4040
&& pg_dump -U \${POSTGRES_USER:-postgres} -d \${POSTGRES_DB:-hackorum} \
4141
--format=plain --no-owner --no-privileges${EXCLUDE_ARGS_STR} \
4242
| gzip -9 > /dumps/public/public-${STAMP}.sql.gz \
43+
&& pg_dump -U \${POSTGRES_USER:-postgres} -d \${POSTGRES_DB:-hackorum} \
44+
--format=plain --schema-only --no-owner --no-privileges${INCLUDE_ARGS_STR} \
45+
| gzip -9 > /dumps/public/private-schema-${STAMP}.sql.gz \
4346
&& pg_dump -U \${POSTGRES_USER:-postgres} -d \${POSTGRES_DB:-hackorum} \
4447
--format=plain --data-only --no-owner --no-privileges${INCLUDE_ARGS_STR} \
4548
| gzip -9 > /dumps/private/private-${STAMP}.sql.gz"

0 commit comments

Comments
 (0)