Instantly share code, notes, and snippets.

What would you like to do?
Dockerized PostgreSQL with Pitrery

Postgres DB with point in time recovery with pitrery

Not yet tested


This image is based on docker's official postgres image. See here for usage information.
Remove or replace the timezone settings in this Dockerfile with your timezone. Currently "Europe/Berlin" is set.
The pitrery backup directory is /backup.

FROM postgres:9.6
RUN echo "Europe/Berlin" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata \
&& mkdir /install \
&& mkdir /backup && chown postgres /backup && chgrp postgres /backup
ADD /install/pitrery.deb
RUN dpkg -i /install/pitrery.deb
RUN sed -i 's|^ARCHIVE_LOCAL.*$|ARCHIVE_LOCAL="yes"|g' /etc/pitrery/pitr.conf \
&& sed -i 's|^BACKUP_IS_LOCAL.*$|BACKUP_IS_LOCAL="yes"|g' /etc/pitrery/pitr.conf \
&& sed -i 's|^BACKUP_DIR.*$|BACKUP_DIR="/backup"|g' /etc/pitrery/pitr.conf \
&& sed -i 's|^PGDATA.*$|PGDATA="/var/lib/postgresql/data"|g' /etc/pitrery/pitr.conf \
&& echo "wal_level = archive" >> /usr/share/postgresql/postgresql.conf.sample \
&& echo "archive_mode = on" >> /usr/share/postgresql/postgresql.conf.sample \
&& echo "archive_command = '/usr/bin/archive_xlog %p'" >> /usr/share/postgresql/postgresql.conf.sample \
&& echo "archive_timeout = 300" >> /usr/share/postgresql/postgresql.conf.sample \
&& cat /etc/pitrery/pitr.conf \
&& cat /usr/share/postgresql/postgresql.conf.sample
VOLUME /backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment