Skip to content

Commit e885e34

Browse files
author
matthias
committed
readme
1 parent 38bf7a6 commit e885e34

File tree

6 files changed

+47
-24
lines changed

6 files changed

+47
-24
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2022-2023 CYBERTEC PostgreSQL International GmbH
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ endif
2626

2727
all: base pgbackrest postgres
2828
base: base
29-
pgbackrest: base pgbackrest
29+
pgbackrest: pgbackrest
3030
postgres: base postgres
3131
postgres-stage: postgres-stage
3232

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CYBERTEC-OS-Container: PostgreSQL-HA-Cluster based on Rocky-Linux
22

3-
<p>CYBERTEC-OS-Container is a Docker suite that combines PostgreSQL, Patroni and etcd to create HA-PostgreSQL clusters based on containers. This suite is also the imagebase for the CYBERTEC-OS operator.</p>
3+
<p>CYBERTEC-OS-Container is a Docker suite that combines PostgreSQL, Patroni and etcd to create HA-PostgreSQL clusters based on containers. This suite is also the imagebase for the CYBERTEC-pg-operator(cpo).</p>
44

55
## Documentation
66

scripts/pgbackrest/backup/start.sh

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,47 @@
44
# call Primary Pod and start basebackup
55
count=0
66
while true ; do
7-
hostName=$(kubectl get pods -l cluster-name=acid-cluster-1,spilo-role=master -o go-template --template '{{range .items}}{{.metadata.name}} {{ break }}{{end}}')
8-
if [ -z "$hostName" ]
9-
then
7+
hostName=$(kubectl get pods -l cluster-name=${SCOPE},spilo-role=master -o go-template --template '{{range .items}}{{.metadata.name}} {{ break }}{{end}}')
8+
if [ -z "$hostName" ]; then
109
sleep 5
1110
output_info "pgBackRest: waiting for primary-Pod"
11+
((count++))
12+
if [ "$count" == 30 ]; then
13+
output_error "pgBackRest: waiting for primary-Pod - Timeout - Skip Step"
14+
skip=1
15+
break
16+
fi
1217
else
1318
break
1419
fi
1520
done
16-
output_info "pgBackRest: Detect Primary-Pod $hostName"
17-
while true ; do
18-
unset error
19-
kubectl exec $hostName -c postgres -- /bin/bash -c 'pgbackrest backup --type=full --stanza=db --repo=1' || { output_error "pgBackRest: Create basebackup failed"; error=true; }
20-
if [ "$error" = true ]; then
21-
sleep 5
22-
else
23-
break;
24-
fi
25-
done
21+
count=0
22+
if [ "$skip" == 1 ]; then
23+
output_error "pgBackRest: No primary pod found - prevent deadlock and start database"
24+
else
25+
output_info "pgBackRest: Detect Primary-Pod $hostName"
26+
while true ; do
27+
unset error
28+
kubectl exec $hostName -c postgres -- /bin/bash -c 'pgbackrest backup --type=full --stanza=db --repo=1' || { output_error "pgBackRest: Create basebackup failed"; error=true; }
29+
if [ "$error" = true ]; then
30+
if [ "$count" == 3 ]; then
31+
output_error "pgBackRest: Basebackup could not be created. Abort init-script";
32+
exit 0
33+
else
34+
((count++))
35+
sleep 5
36+
fi
37+
else
38+
break;
39+
fi
40+
done
41+
42+
output_info "pgBackRest: Update Restore-Configmap"
43+
configmap="${SCOPE}-pgbackrest-restore"
44+
kubectl get cm $configmap -o yaml | \
45+
sed -e 's|restore_basebackup: "false"|restore_basebackup: "true"|' | \
46+
kubectl apply -f -
2647

27-
output_info "pgBackRest: Update Restore-Configmap"
28-
configmap="${SCOPE}-pgbackrest-restore"
29-
kubectl get cm $configmap -o yaml | \
30-
sed -e 's|restore_basebackup: "false"|restore_basebackup: "true"|' | \
31-
kubectl apply -f -
48+
output_info "pgBackRest: Backup complete"
49+
fi
3250

33-
output_info "pgBackRest: Backup complete"

scripts/pgbackrest/restore/start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ if [ -d "$pgroot/data_bootstrap" ]; then
2323
fi
2424

2525
# Add Path
26-
restore_command="$restore_opts --stanza=db --pg1-path=$pgdata --delta --link-map=pg_wal=$pgroot/data_wal"
26+
restore_command="$restore_opts --stanza=db --pg1-path=$pgdata --delta --link-map=pg_wal=$pgroot/data_wal --target-action=promote"
2727

2828
# Do Restore
2929
output_info "pgBackRest: start restore: Defined options: $restore_command"
30-
pgbackrest restore $restore_command || { output_error "pgBackRest: Restore failed"; exit 0; } #<< /home/postgres/pgdata/pgbackrest/log/restore-pod.log
30+
bash -xc "pgbackrest restore ${restore_command}" || { output_error "pgBackRest: Restore failed"; exit 0; } #<< /home/postgres/pgdata/pgbackrest/log/restore-pod.log
3131
output_info "Defined Data-DIR: $pgdata"
3232
# Check Restore
3333
until [ "${recovery=}" = 'f' ]; do

scripts/postgres/init_pgbackrest.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ else
77
mkdir -p /home/postgres/pgdata/pgbackrest/log
88
echo "Created: Folder structure was created"
99
fi
10+
if [ -d "/home/postgres/pgdata/pgbackrest/spool-path" ]; then
11+
echo "Skip: Spool-Folder already exists ... "
12+
else
13+
mkdir -p /home/postgres/pgdata/pgbackrest/spool-path
14+
echo "Created: Spool-Folder was created"
15+
fi
1016
# Create Stanza and run Init-Backup
1117
stanza=$(pgbackrest info --output=json)
1218
if [ "$stanza" == "[]" ]; then

0 commit comments

Comments
 (0)