Skip to content

Commit 652443a

Browse files
authored
add support for postgresql 11 (#28)
Signed-off-by: Mehedi Hasan <[email protected]>
1 parent 9ef4816 commit 652443a

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

scripts/restore.sh

+45-36
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,53 @@ if [[ "${WALG_BASE_BACKUP_NAME:-0}" != "0" ]]; then
1111
wal-g backup-fetch $PGDATA $WALG_BASE_BACKUP_NAME
1212
fi
1313

14-
## ****************** Recovery config 11 **************************
15-
#touch /tmp/recovery.conf
16-
#echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/recovery.conf
17-
#echo "standby_mode = on" >>/tmp/recovery.conf
18-
#echo "trigger_file = '/run_scripts/tmp/pg-failover-trigger'" >>/tmp/recovery.conf # [ name whose presence ends recovery]
19-
##echo "recovery_target_timeline = 'latest'" >>/tmp/recovery.conf
20-
##echo "recovery_target = 'immediate'" >>/tmp/recovery.conf
21-
#echo "recovery_target_action = 'promote'" >>/tmp/recovery.conf
22-
#mv /tmp/recovery.conf "$PGDATA/recovery.conf"
23-
#
24-
## setup postgresql.conf
25-
#touch /tmp/postgresql.conf
26-
#echo "wal_level = replica" >>/tmp/postgresql.conf
27-
#echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS
28-
#
29-
#echo "wal_keep_segments = 64" >>/tmp/postgresql.conf
30-
#
31-
#echo "wal_log_hints = on" >>/tmp/postgresql.conf
32-
33-
# ****************** Recovery config 12, 13, 14 **************************
34-
touch $PGDATA/recovery.signal
35-
36-
# setup postgresql.conf
37-
touch /tmp/postgresql.conf
38-
echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/postgresql.conf
39-
#echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
40-
if [[ "${PITR_TIME:-0}" != "latest" ]]; then
41-
echo "recovery_target_time = '$PITR_TIME'" >>/tmp/postgresql.conf
14+
# check postgresql veriosn
15+
16+
if [[ "$PG_MAJOR" == "11" ]]; then
17+
18+
# ****************** Recovery config 11 **************************
19+
touch /tmp/recovery.conf
20+
echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/recovery.conf
21+
echo "standby_mode = on" >>/tmp/recovery.conf
22+
echo "trigger_file = '/run_scripts/tmp/pg-failover-trigger'" >>/tmp/recovery.conf # [ name whose presence ends recovery]
23+
if [[ "${PITR_TIME:-0}" != "latest" ]]; then
24+
echo "recovery_target_time = '$PITR_TIME'" >>/tmp/recovery.conf
25+
else
26+
echo "recovery_target_timeline = 'latest'" >>/tmp/recovery.conf
27+
fi
28+
echo "recovery_target_action = 'promote'" >>/tmp/recovery.conf
29+
mv /tmp/recovery.conf "$PGDATA/recovery.conf"
30+
31+
# setup postgresql.conf
32+
touch /tmp/postgresql.conf
33+
echo "wal_level = replica" >>/tmp/postgresql.conf
34+
echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS
35+
36+
echo "wal_keep_segments = 64" >>/tmp/postgresql.conf
37+
38+
echo "wal_log_hints = on" >>/tmp/postgresql.conf
4239
else
43-
echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
44-
fi
45-
echo "recovery_target_action = 'promote'" >>/tmp/postgresql.conf
46-
echo "wal_level = replica" >>/tmp/postgresql.conf
47-
echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS
40+
# ****************** Recovery config 12, 13, 14 **************************
41+
touch $PGDATA/recovery.signal
42+
43+
# setup postgresql.conf
44+
touch /tmp/postgresql.conf
45+
echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/postgresql.conf
46+
#echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
47+
if [[ "${PITR_TIME:-0}" != "latest" ]]; then
48+
echo "recovery_target_time = '$PITR_TIME'" >>/tmp/postgresql.conf
49+
else
50+
echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
51+
fi
52+
echo "recovery_target_action = 'promote'" >>/tmp/postgresql.conf
53+
echo "wal_level = replica" >>/tmp/postgresql.conf
54+
echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS
4855

49-
echo "wal_keep_size = 64" >>/tmp/postgresql.conf
50-
echo "hot_standby = on" >>/tmp/postgresql.conf
51-
echo "wal_log_hints = on" >>/tmp/postgresql.conf
56+
echo "wal_keep_size = 64" >>/tmp/postgresql.conf
57+
echo "hot_standby = on" >>/tmp/postgresql.conf
58+
echo "wal_log_hints = on" >>/tmp/postgresql.conf
59+
60+
fi
5261

5362
# ****************** Recovery config 12 **************************
5463
# we are not doing any archiving by default but it's better to have this config in our postgresql.conf file in case of customization.

0 commit comments

Comments
 (0)