kopia lustrzana https://github.com/kartoza/docker-postgis
fix pgbackrest not creating backup
rodzic
375b76294e
commit
3085b9e89f
17
Dockerfile
17
Dockerfile
|
@ -76,8 +76,8 @@ ARG POSTGRES_MAJOR_VERSION=16
|
|||
ARG POSTGIS_MAJOR_VERSION=3
|
||||
ARG POSTGIS_MINOR_RELEASE=4
|
||||
# https://packagecloud.io/timescale/timescaledb
|
||||
ARG TIMESCALE_VERSION=2-2.11.2
|
||||
ARG BUILD_TIMESCALE=false
|
||||
ARG TIMESCALE_VERSION=2
|
||||
ARG BUILD_TIMESCALE=true
|
||||
|
||||
|
||||
|
||||
|
@ -107,10 +107,13 @@ RUN wget -qO- https://pgbackrest.org/pgbackrest.gpg | tee /etc/apt/trusted.gpg.d
|
|||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create necessary directories for pgBackRest
|
||||
RUN mkdir -p /etc/pgbackrest /var/log/pgbackrest /var/lib/pgbackrest
|
||||
RUN mkdir -p /etc/pgbackrest /var/log/pgbackrest /var/lib/pgbackrest /tmp/pgbackrest/
|
||||
|
||||
# Set appropriate permissions for pgBackRest directories
|
||||
RUN chown -R postgres:postgres /etc/pgbackrest /var/log/pgbackrest /var/lib/pgbackrest
|
||||
RUN chmod 777 /tmp/pgbackrest/
|
||||
RUN touch /var/log/pgbackrest/postgres-stanza-create.log
|
||||
RUN chmod 777 /var/log/pgbackrest/postgres-stanza-create.log
|
||||
|
||||
# Copy pgBackRest configuration file
|
||||
COPY ./pgbackrest/pgbackrest.conf /etc/pgbackrest/pgbackrest.conf
|
||||
|
@ -165,6 +168,14 @@ RUN echo 'root:' | chpasswd -e
|
|||
# Start the SSH service
|
||||
RUN service ssh start
|
||||
|
||||
# Enable archive_mode in postgresql.conf
|
||||
# Enable archive_mode in postgresql.conf
|
||||
RUN set -eux \
|
||||
&& echo "archive_mode = on" >> /etc/postgresql/${POSTGRES_MAJOR_VERSION}/main/postgresql.conf \
|
||||
&& echo "archive_command = 'pgbackrest --stanza=postgres archive-push %p'" >> /etc/postgresql/${POSTGRES_MAJOR_VERSION}/main/postgresql.conf \
|
||||
&& echo "archive_timeout = 120s" >> /etc/postgresql/${POSTGRES_MAJOR_VERSION}/main/postgresql.conf
|
||||
|
||||
|
||||
# TODO a case insensitive match would be more robust
|
||||
RUN if [ "${BUILD_TIMESCALE}" = "true" ]; then \
|
||||
export DEBIAN_FRONTEND=noninteractive && \
|
||||
|
|
|
@ -20,15 +20,11 @@ create_pgbackrest_dirs() {
|
|||
chmod 700 "$dir_path"
|
||||
}
|
||||
|
||||
# Switch to postgres user to create directories and permissions
|
||||
su - postgres -c "
|
||||
create_pgbackrest_dirs '$LOG_DIR'
|
||||
create_pgbackrest_dirs '$TMP_DIR'
|
||||
create_pgbackrest_dirs '$BACKUP_DIR'
|
||||
"
|
||||
# Create directories as root
|
||||
create_pgbackrest_dirs "$LOG_DIR"
|
||||
create_pgbackrest_dirs "$TMP_DIR"
|
||||
create_pgbackrest_dirs "$BACKUP_DIR"
|
||||
|
||||
# Create a pgBackRest stanza as postgres user
|
||||
# Switch to postgres user to create pgBackRest stanza and run backup
|
||||
su - postgres -c "pgbackrest --stanza=postgres stanza-create"
|
||||
|
||||
# Run pgBackRest backup as postgres user
|
||||
su - postgres -c "pgbackrest --stanza=postgres backup"
|
||||
|
|
|
@ -4,7 +4,6 @@ repo1-retention-full=2
|
|||
backup-user=root
|
||||
|
||||
[postgres]
|
||||
pg1-host=postgres
|
||||
pg1-path=/var/lib/postgresql/data
|
||||
pg1-path=/var/lib/postgresql/16/main
|
||||
pg1-user=postgres
|
||||
pg1-port=5432
|
Ładowanie…
Reference in New Issue