10 Restoring: the database alone
For damaged or unwanted data, with the files still good. This loses everything since the backup. Files added since then stay on the volume with no record. They may be the only copies of that work, so review them before a person removes any.
-
Take a backup of what is there, then stop the stack and remove only the database volume. Run these as one command, so a failed backup stops it before anything is removed:
PROJECT="$(docker compose config | sed -n 's/^name: *//p' | head -n 1)" && ./deploy/backup.sh /var/backups/grc-before-restore 3650 && docker compose --profile tls down && docker volume rm "${PROJECT}_pgdata18"PROJECTis this directory's own project, so this cannot name another instance on the host.downwithout-vleaves the volumes, and with the profile named it stops the bundled Caddy too, if you use it.If the database is too damaged to dump,
backup.shfails, and that is when the copy matters most. Take a raw copy of the volume instead, with the stack stopped. It can be read only by the same PostgreSQL version:PROJECT="$(docker compose config | sed -n 's/^name: *//p' | head -n 1)" && docker compose --profile tls down && docker run --rm -v "${PROJECT}_pgdata18:/data:ro" alpine:3.20 tar -C /data -czf - . > /var/backups/grc-before-restore/pgdata-raw.tar.gz && tar -tzf /var/backups/grc-before-restore/pgdata-raw.tar.gz > /dev/null && docker volume rm "${PROJECT}_pgdata18" -
Restore, then run
migrate, withweband the worker off:./deploy/restore.sh --db-only /var/backups/grc/db-<stamp>.dump && docker compose run --rm migrate -
Follow "After any restore".