From 86090ce7f8edd15032226d9ebf2b4d53f71af76b Mon Sep 17 00:00:00 2001 From: Dave Conroy Date: Thu, 26 Oct 2017 11:32:32 -0700 Subject: [PATCH] 1.3 - Update Postgres Client to support backing up 10.x hosts --- CHANGELOG.md | 9 ++-- Dockerfile | 67 ++++++++++++++++++++++-- install/etc/s6/services/10-db-backup/run | 3 ++ 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27cb206..058c099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,17 @@ +## 1.3 - 2017-10-25 - -## 1.2 - 2017-10-19 - dave at tiredofit dot ca +* Remove Alpine postgres package and recompile version 10 + +## 1.2 - 2017-10-19 - * Syntax Error Fix * Fix some environment variables for Postgres and Redis -## 1.1 - 2017-09-14 - dave at tiredofit dot ca +## 1.1 - 2017-09-14 - * Added CouchDB -## 1.0 - 2017-09-14 - dave at tiredofit dot ca +## 1.0 - 2017-09-14 - * Initial Release * Alpine:Edge diff --git a/Dockerfile b/Dockerfile index 79603f4..e59fcca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM tiredofit/alpine:edge +FROM registry.selfdesign.org/docker/alpine:edge LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)" ### Set Environment Variables @@ -13,11 +13,72 @@ LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)" influxdb@testing \ mongodb-tools \ mysql-client \ - postgresql-client \ redis \ - xz && \ + xz + +### Build Postgres 10 + RUN apk add --no-cache --virtual .fetch-deps \ + ca-certificates \ + openssl \ + && \ + mkdir -p /usr/src/postgresql && \ + curl https://ftp.postgresql.org/pub/source/v10.0/postgresql-10.0.tar.bz2 | tar xvfj - --strip 1 -C /usr/src/postgresql && \ + + apk add --no-cache --virtual .build-deps \ + bison \ + coreutils \ + dpkg-dev dpkg \ + flex \ + gcc \ + libc-dev \ + libedit-dev \ + libxml2-dev \ + libxslt-dev \ + make \ + openssl-dev \ + perl-utils \ + perl-ipc-run \ + util-linux-dev \ + zlib-dev \ + && \ + cd /usr/src/postgresql && \ + awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new && \ + grep '/var/run/postgresql' src/include/pg_config_manual.h.new && \ + mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h && \ + gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" && \ + wget -O config/config.guess 'https://git.savannah.gnu.org/cgit/config.git/plain/config.guess?id=7d3d27baf8107b630586c962c057e22149653deb' && \ + wget -O config/config.sub 'https://git.savannah.gnu.org/cgit/config.git/plain/config.sub?id=7d3d27baf8107b630586c962c057e22149653deb' && \ + ./configure \ + --build="$gnuArch" \ + --enable-integer-datetimes \ + --enable-thread-safety \ + --enable-tap-tests \ + --disable-rpath \ + --with-uuid=e2fs \ + --with-gnu-ld \ + --with-pgport=5432 \ + --with-system-tzdata=/usr/share/zoneinfo \ + --prefix=/usr/local \ + --with-includes=/usr/local/include \ + --with-libraries=/usr/local/lib \ + \ + --with-openssl \ + --with-libxml \ + --with-libxslt && \ + make -j "$(nproc)" world && \ + make install-world && \ + make -C contrib install && \ + \ + apk del .fetch-deps .build-deps && \ + cd / && \ + rm -rf \ + /usr/src/postgresql \ + /usr/local/share/doc \ + /usr/local/share/man && \ + find /usr/local -name '*.a' -delete && \ rm -rf /var/cache/apk/* + ### S6 Setup ADD install / diff --git a/install/etc/s6/services/10-db-backup/run b/install/etc/s6/services/10-db-backup/run index 8b31e27..78e3eb9 100755 --- a/install/etc/s6/services/10-db-backup/run +++ b/install/etc/s6/services/10-db-backup/run @@ -128,12 +128,15 @@ function backup_pgsql() { for db in $DATABASES; do echo "** [db-backup] Dumping database: $db" TARGET=pgsql_${db}_${DBHOST}_${now}.sql + export PGPASSWORD=${DBPASS} + pg_dump -h ${DBHOST} -p ${DBPORT}-U ${DBUSER} $db > ${TMPDIR}/${TARGET} generate_md5 compression move_backup done else + export PGPASSWORD=${DBPASS} pg_dump -h ${DBHOST} -U ${DBUSER} $db > ${TMPDIR}/${TARGET} generate_md5 compression