diff --git a/image/Dockerfile b/image/Dockerfile index e23a0ce..bfd1353 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -2,9 +2,14 @@ FROM debian:stable RUN apt-get update && apt-get install -y gettext-base python-pip curl git +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \ + curl -sk https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ + apt-get update && apt-get install --no-install-recommends -y postgresql-client-9.3 && \ + apt-get clean -y + WORKDIR /app RUN curl -sSL -o /usr/local/bin/etcdctl https://s3-us-west-2.amazonaws.com/opdemand/etcdctl-v0.4.6 && chmod +x /usr/local/bin/etcdctl RUN pip install python-dateutil; pip install git+https://github.com/s3tools/s3cmd COPY backup.sh /app/backup.sh COPY s3cfg /app/s3cfg -CMD ./backup.sh +CMD ./backup.sh \ No newline at end of file diff --git a/image/backup.sh b/image/backup.sh index e497e03..d71b53a 100755 --- a/image/backup.sh +++ b/image/backup.sh @@ -39,6 +39,10 @@ done DEIS_CONFIG_FILE=${DEIS_CONFIG_FILE:-~/.s3cfg.deis} AWS_CONFIG_FILE=${AWS_CONFIG_FILE:-~/.s3cfg.aws} +DATABASE_HOST="$(etcdctl -C ${ETCD} get /deis/database/host)" +DATABASE_PORT="$(etcdctl -C ${ETCD} get /deis/database/port)" +DATABASE_USERNAME="$(etcdctl -C ${ETCD} get /deis/database/adminUser)" +DATABASE_PASSWORD="$(etcdctl -C ${ETCD} get /deis/database/adminPass)" CEPH_ACCESS_KEY="$(etcdctl -C ${ETCD} get deis/store/gateway/accessKey)" CEPH_SECRET_KEY="$(etcdctl -C ${ETCD} get deis/store/gateway/secretKey)" DATABASE_BUCKET_NAME="$(etcdctl -C ${ETCD} get /deis/database/bucketName)" @@ -61,6 +65,10 @@ cat s3cfg | ACCESS_KEY=${CEPH_ACCESS_KEY} SECRET_KEY=${CEPH_SECRET_KEY} HOST_BAS set -x +# Dump a text backup of the database +mkdir -p ${BACKUP_DIR} +PGHOST=${DATABASE_HOST} PGPORT=${DATABASE_PORT} PGUSER=${DATABASE_USERNAME} PGPASSWORD=${DATABASE_PASSWORD} pg_dumpall > ${BACKUP_DIR}/database.sql + # Copy the deis mkdir -p "${BACKUP_DIR}/${DATABASE_BUCKET_NAME}/" s3cmd -c "${DEIS_CONFIG_FILE}" get -r "s3://${DATABASE_BUCKET_NAME}/" "${BACKUP_DIR}/${DATABASE_BUCKET_NAME}" @@ -68,4 +76,4 @@ mkdir -p "${BACKUP_DIR}/${REGISTRY_BUCKET_NAME}/" s3cmd -c "${DEIS_CONFIG_FILE}" get -r "s3://${REGISTRY_BUCKET_NAME}/" "${BACKUP_DIR}/${REGISTRY_BUCKET_NAME}" # Copy the local db_wal bucket to AWS -s3cmd -c "${AWS_CONFIG_FILE}" put -r "${BACKUP_DIR}" "s3://${AWS_BACKUP_BUCKET}/" +s3cmd -c "${AWS_CONFIG_FILE}" put -r "${BACKUP_DIR}" "s3://${AWS_BACKUP_BUCKET}/" \ No newline at end of file