Skip to content

Commit e6ce000

Browse files
authored
reduce tracing of dumps and include Pg12 (zalando#791)
1 parent 077f9af commit e6ce000

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

docker/logical-backup/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apt-get update \
1919
&& curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
2020
&& apt-get update \
2121
&& apt-get install --no-install-recommends -y \
22+
postgresql-client-12 \
2223
postgresql-client-11 \
2324
postgresql-client-10 \
2425
postgresql-client-9.6 \
@@ -28,6 +29,6 @@ RUN apt-get update \
2829

2930
COPY dump.sh ./
3031

31-
ENV PG_DIR=/usr/lib/postgresql/
32+
ENV PG_DIR=/usr/lib/postgresql
3233

3334
ENTRYPOINT ["/dump.sh"]

docker/logical-backup/dump.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ set -o nounset
66
set -o pipefail
77
IFS=$'\n\t'
88

9-
# make script trace visible via `kubectl logs`
10-
set -o xtrace
11-
129
ALL_DB_SIZE_QUERY="select sum(pg_database_size(datname)::numeric) from pg_database;"
1310
PG_BIN=$PG_DIR/$PG_VERSION/bin
1411
DUMP_SIZE_COEFF=5
12+
ERRORCOUNT=0
1513

1614
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
1715
K8S_API_URL=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1
@@ -42,9 +40,9 @@ function aws_upload {
4240

4341
[[ ! -z "$EXPECTED_SIZE" ]] && args+=("--expected-size=$EXPECTED_SIZE")
4442
[[ ! -z "$LOGICAL_BACKUP_S3_ENDPOINT" ]] && args+=("--endpoint-url=$LOGICAL_BACKUP_S3_ENDPOINT")
45-
[[ ! "$LOGICAL_BACKUP_S3_SSE" == "" ]] && args+=("--sse=$LOGICAL_BACKUP_S3_SSE")
43+
[[ ! -z "$LOGICAL_BACKUP_S3_SSE" ]] && args+=("--sse=$LOGICAL_BACKUP_S3_SSE")
4644

47-
aws s3 cp - "$PATH_TO_BACKUP" "${args[@]//\'/}" --debug
45+
aws s3 cp - "$PATH_TO_BACKUP" "${args[@]//\'/}"
4846
}
4947

5048
function get_pods {
@@ -93,4 +91,9 @@ for search in "${search_strategy[@]}"; do
9391

9492
done
9593

94+
set -x
9695
dump | compress | aws_upload $(($(estimate_size) / DUMP_SIZE_COEFF))
96+
[[ ${PIPESTATUS[0]} != 0 || ${PIPESTATUS[1]} != 0 || ${PIPESTATUS[2]} != 0 ]] && (( ERRORCOUNT += 1 ))
97+
set +x
98+
99+
exit $ERRORCOUNT

0 commit comments

Comments
 (0)