These docs are for v5.0. Click to read the latest docs for v2023.

Database Backups

Create a Backup

The script below will run a on-off container that will run pg_dump and write the results to the file backup.db. This process could take a while, depending on the size of the database.

docker run -it --rm --link codecov-postgres:postgres postgres pg_dump -Fc -h postgres -U postgres > backup.db

Recover From a Backup

The script below is used to run a on-off container with the backup file mounted. pg_restore will run with 2 processes.

Concerning -j2, the optimal value for this option depends on the hardware setup of the server, of the client, and of the network. Factors include the number of CPU cores, and the disk setup. A good place to start is the number of CPU cores on the server, but values larger than that can also lead to faster restore times in many cases. Of course, values that are too high will lead to decreased performance because of thrashing.

docker run -it --rm -v "$PWD/backup.db:/backup.db" --link codecov-postgres:postgres postgres pg_restore -h postgres -U postgres -j2 /backup.db