Skip to content

Instantly share code, notes, and snippets.

@kekru
Last active August 15, 2017 17:28
Show Gist options
  • Save kekru/c9e22fed6534f4493fb39b0b1a977c49 to your computer and use it in GitHub Desktop.
Save kekru/c9e22fed6534f4493fb39b0b1a977c49 to your computer and use it in GitHub Desktop.
Dockerized PostgreSQL with Pitrery

Postgres DB with point in time recovery with pitrery

Not yet tested

Usage

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 https://dl.dalibo.com/public/pitrery/debian/pitrery_1.13-1_all.deb /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