Skip to content


Docker Pulls GitHub Stars Compose Templates


pgBackup: Backup PostgresSQL to the local filesystem with periodic rotating backups


Set your postgres host, username and password in the .env file along with a comma separated list of databases you want to backup.

By default, backups run daily. Change PGBACKUP_SCHEDULE to any valid cron schedule to modify the default.

For extra security, it is recommended to limit permissions on the backup folder to a priviledged user. Modify docker-compose.override.yml as below.

If you are using postgres docker container, add a dependency to the container

    user: postgres:postgres
      - postgres

Manually trigger a backup

docker exec -it pgbackup ./

Restore from latest backup

If the database already exists, drop it. Create a database

docker exec -it <postgres_container> /bin/sh -c "zcat /storage/backups/postgres/last/<db_name>-latest.sql.gz | psql --username=<username> --dbname=<db_name> -W"