4 Backing up: VM or Docker
4.1 The included script
deploy/backup.sh writes db-<stamp>.dump and uploads-<stamp>.tar.gz. Run it from the installation
directory, nightly from cron, and copy the result off the host:
0 2 * * * cd /srv/grc && ./deploy/backup.sh /var/backups/grc 14 >> /var/log/grc-backup.log 2>&1
pg_dump gives a consistent copy while the application
runs. The Administrator's Guide, under Backup and
Restore, covers scheduling, encrypting with age and copying off the server. Leave out .partial-* when you copy: a run killed
outright leaves one behind, unencrypted until age has run, and the next run removes it after a day. A backup on the same disk
as the database does not survive losing that disk. Alert on a failed or missing run.
4.2 Other tools that fit
- restic (or similar) to copy the script's output, encrypted, to another machine or object store.
- VM or volume snapshots. They count only if they cover the database and the uploads volume at the same moment, leave the host, and are restored in a drill. A snapshot of a running database restores as it would after a power cut: PostgreSQL recovers by itself, provided its volume was captured whole. Take separate schedules for the two volumes and you can pair mismatched rows and files.
- pgBackRest or WAL-G for continuous archiving and
point-in-time recovery, when a day's loss is too much. These work on the whole PostgreSQL cluster and need
setup inside the
dbcontainer. Neither has been tried with this stack.