Skip to content

Commit ee2873b

Browse files
authored
Merge pull request #77 from cybertec-postgresql/pgbackrest
Pgbackrest
2 parents f374317 + 6b9ed90 commit ee2873b

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ postgres-oracle-build:
134134
postgres-oracle: postgres-oracle-build
135135

136136
pgbouncer-build:
137-
docker build $(ROOTPATH) \
137+
docker build $(ROOTPATH) --no-cache \
138138
--file $(ROOTPATH)/docker/pgbouncer/Dockerfile \
139139
--tag cybertec-pg-container/pgbouncer:$(IMAGE_TAG) \
140140
--build-arg BASE_IMAGE=$(BASE_IMAGE) \

docker/pgbackrest/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ COPY --from=micro / /
131131

132132
ARG PGVERSION
133133

134+
ENV PATH=$PATH:/usr/pgsql-$PGVERSION/bin \
135+
LD_LIBRARY_PATH=/usr/pgsql-$PGVERSION/lib:$LD_LIBRARY_PATH
136+
134137
LABEL org.opencontainers.image.source=https://github.com/cybertec-postgresql/CYBERTEC-pg-container
135138
LABEL org.opencontainers.image.description="CYBERTEC-PG-Container - pgBackRest-Container for restore-Container and as Repo-Host"
136139
LABEL org.opencontainers.image.licenses=Apache-2.0

launcher/postgres/launch.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ fi
1818
sysctl -w vm.dirty_background_bytes=67108864 > /dev/null 2>&1
1919
sysctl -w vm.dirty_bytes=134217728 > /dev/null 2>&1
2020
mkdir -p "$PGLOG" "$PGDATA" "$RW_DIR/postgresql" "$RW_DIR/tmp" "$RW_DIR/certs"
21-
if [ "$(id -u)" -ne 0 ]; then
22-
sed -e "s/^postgres:x:[^:]*:[^:]*:/postgres:x:$(id -u):$(id -g):/" /etc/passwd > "$RW_DIR/tmp/passwd"
23-
cat "$RW_DIR/tmp/passwd" > /etc/passwd
24-
rm "$RW_DIR/tmp/passwd"
25-
fi
21+
# if [ "$(id -u)" -ne 0 ]; then
22+
# sed -e "s/^postgres:x:[^:]*:[^:]*:/postgres:x:$(id -u):$(id -g):/" /etc/passwd > "$RW_DIR/tmp/passwd"
23+
# cat "$RW_DIR/tmp/passwd" > /etc/passwd
24+
# rm "$RW_DIR/tmp/passwd"
25+
# fi
2626

2727
## Ensure all logfiles exist, most appliances will have
2828
## a foreign data wrapper pointing to these files

scripts/pgbackrest/repo-host/start.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,33 @@ status=$(echo $stanza | jq '.[0].status.code')
1616

1717
if [ "$db" == "[]" ] && [ "$archive" == "[]" ] || [ "$status" == "1" ]; then
1818
# Check if Primary is ready
19-
pgbackrest stanza-create --stanza=db
19+
count=0
20+
while true
21+
do
22+
pgbackrest stanza-create --stanza=db
23+
returnCode=$?
24+
((count++))
25+
26+
if [ "$returnCode" -eq 56 ]; then
27+
echo "WARNING: pgbackrest could not create stanza – No primary found - Attempt $count / 10"
28+
sleep 5
29+
elif [ "$returnCode" -eq 0 ]; then
30+
echo "INFO: pgbackrest stanza successfully created."
31+
break
32+
fi
33+
34+
if [ "$count" -eq 10 ]; then
35+
echo "ERROR: pgbackrest could not create stanza - reached max attempts."
36+
break
37+
fi
38+
done
39+
echo "INFO: create initial backup"
2040
pgbackrest backup --type=full --stanza=db --repo=1
21-
echo "Finished: pgBackRest is ready for use"
41+
echo "INFO: pgBackRest is ready for use"
2242
else
2343
backupCount=$(pgbackrest info --output=json | jq '.[0].backup'| jq length)
2444
if [ "$backupCount" == "0" ]; then
2545
pgbackrest backup --type=full --stanza=db --repo=1
26-
echo "Finished: pgBackRest is ready for use"
46+
echo "INFO: pgBackRest is ready for use"
2747
fi
2848
fi

0 commit comments

Comments
 (0)