Skip to content

Commit 47656c0

Browse files
committed
fix(003_restore_from_backup.sh): ignore script exit 1
1 parent a90cf41 commit 47656c0

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ COPY --from=mc /usr/bin/mc /bin/mc
77

88
ENV PGDATA $PGDATA/$PG_MAJOR
99
ENV WALG_ENVDIR /etc/wal-g.d/env
10-
ADD https://github.com/wal-g/wal-g/releases/download/v0.2.4/wal-g.linux-amd64.tar.gz /bin
10+
ADD https://github.com/wal-g/wal-g/releases/download/v0.2.9/wal-g.linux-amd64.tar.gz /bin
1111

1212
RUN mkdir -p $WALG_ENVDIR \
1313
&& tar -xvzf /bin/wal-g.linux-amd64.tar.gz -C /bin && rm /bin/wal-g.linux-amd64.tar.gz \

contrib/ci/test-minio.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ echo "ls /home/minio/*/*/basebackups_005" > "${CURRENT_DIR}"/tmp/bin/backups.sh
3030
MINIO_JOB=$(docker run -d \
3131
-v "${CURRENT_DIR}"/tmp/bin:/tmp/bin \
3232
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/objectstore/creds \
33-
quay.io/drycc/minio:canary server /home/minio/)
33+
drycc/minio:v1.0.1 server /home/minio/)
3434

3535
# boot postgres, linking the minio container and setting DRYCC_MINIO_SERVICE_HOST and DRYCC_MINIO_SERVICE_PORT
3636
PG_CMD="docker run -d --link ${MINIO_JOB}:minio -e PGCTLTIMEOUT=1200 \

rootfs/docker-entrypoint-initdb.d/003_restore_from_backup.sh

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
#!/usr/bin/env bash
22

3-
cat << EOF >> "$PGDATA/postgresql.conf"
4-
wal_level = archive
5-
archive_mode = on
6-
archive_command = 'envdir "${WALG_ENVDIR}" wal-g wal-push %p'
7-
archive_timeout = 60
8-
max_connections = 1024
9-
EOF
10-
11-
# ensure $PGDATA has the right permissions
12-
chown -R postgres:postgres "$PGDATA"
13-
chmod 0700 "$PGDATA"
14-
15-
# reboot the server for wal_level to be set before backing up
16-
echo "Rebooting postgres to enable archive mode"
17-
su-exec postgres pg_ctl -D "$PGDATA" -w restart
18-
193
# check if there are any backups -- if so, let's restore
204
# we could probably do better than just testing number of lines -- one line is just a heading, meaning no backups
215

226
if [[ $(envdir "$WALG_ENVDIR" wal-g backup-list | wc -l) -gt "1" ]]; then
237
echo "Found backups. Restoring from backup..."
24-
su-exec postgres pg_ctl -D "$PGDATA" -w stop
8+
{
9+
su-exec postgres pg_ctl -D "$PGDATA" -w stop > /dev/null 2>&1
10+
} || {
11+
echo "ignore script errors"
12+
}
2513
rm -rf "$PGDATA"
2614
envdir "$WALG_ENVDIR" wal-g backup-fetch "$PGDATA" LATEST
2715
cat << EOF > "$PGDATA/postgresql.conf"
@@ -56,6 +44,22 @@ EOF
5644
su-exec postgres pg_ctl -D "$PGDATA" \
5745
-o "-c listen_addresses=''" \
5846
-w start
47+
else
48+
cat << EOF >> "$PGDATA/postgresql.conf"
49+
wal_level = archive
50+
archive_mode = on
51+
archive_command = 'envdir "${WALG_ENVDIR}" wal-g wal-push %p'
52+
archive_timeout = 60
53+
max_connections = 1024
54+
EOF
55+
56+
# ensure $PGDATA has the right permissions
57+
chown -R postgres:postgres "$PGDATA"
58+
chmod 0700 "$PGDATA"
59+
60+
# reboot the server for wal_level to be set before backing up
61+
echo "Rebooting postgres to enable archive mode"
62+
su-exec postgres pg_ctl -D "$PGDATA" -w restart
5963
fi
6064

6165
# ensure $PGDATA has the right permissions

0 commit comments

Comments
 (0)