Skip to content

Commit

Permalink
add support for walg postgresql 11 (#29)
Browse files Browse the repository at this point in the history
Signed-off-by: Mehedi Hasan <[email protected]>
  • Loading branch information
heheh13 authored Dec 8, 2023
1 parent dfbdb6f commit 75d90dc
Showing 1 changed file with 45 additions and 36 deletions.
81 changes: 45 additions & 36 deletions scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,53 @@ if [[ "${WALG_BASE_BACKUP_NAME:-0}" != "0" ]]; then
wal-g backup-fetch $PGDATA $WALG_BASE_BACKUP_NAME
fi

## ****************** Recovery config 11 **************************
#touch /tmp/recovery.conf
#echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/recovery.conf
#echo "standby_mode = on" >>/tmp/recovery.conf
#echo "trigger_file = '/run_scripts/tmp/pg-failover-trigger'" >>/tmp/recovery.conf # [ name whose presence ends recovery]
##echo "recovery_target_timeline = 'latest'" >>/tmp/recovery.conf
##echo "recovery_target = 'immediate'" >>/tmp/recovery.conf
#echo "recovery_target_action = 'promote'" >>/tmp/recovery.conf
#mv /tmp/recovery.conf "$PGDATA/recovery.conf"
#
## setup postgresql.conf
#touch /tmp/postgresql.conf
#echo "wal_level = replica" >>/tmp/postgresql.conf
#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
#
#echo "wal_keep_segments = 64" >>/tmp/postgresql.conf
#
#echo "wal_log_hints = on" >>/tmp/postgresql.conf

# ****************** Recovery config 12, 13, 14 **************************
touch $PGDATA/recovery.signal

# setup postgresql.conf
touch /tmp/postgresql.conf
echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/postgresql.conf
#echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
if [[ "${PITR_TIME:-0}" != "latest" ]]; then
echo "recovery_target_time = '$PITR_TIME'" >>/tmp/postgresql.conf
# check postgresql veriosn

if [[ "$PG_MAJOR" == "11" ]]; then

# ****************** Recovery config 11 **************************
touch /tmp/recovery.conf
echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/recovery.conf
echo "standby_mode = on" >>/tmp/recovery.conf
echo "trigger_file = '/run_scripts/tmp/pg-failover-trigger'" >>/tmp/recovery.conf # [ name whose presence ends recovery]
if [[ "${PITR_TIME:-0}" != "latest" ]]; then
echo "recovery_target_time = '$PITR_TIME'" >>/tmp/recovery.conf
else
echo "recovery_target_timeline = 'latest'" >>/tmp/recovery.conf
fi
echo "recovery_target_action = 'promote'" >>/tmp/recovery.conf
mv /tmp/recovery.conf "$PGDATA/recovery.conf"

# setup postgresql.conf
touch /tmp/postgresql.conf
echo "wal_level = replica" >>/tmp/postgresql.conf
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

echo "wal_keep_segments = 64" >>/tmp/postgresql.conf

echo "wal_log_hints = on" >>/tmp/postgresql.conf
else
echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
fi
echo "recovery_target_action = 'promote'" >>/tmp/postgresql.conf
echo "wal_level = replica" >>/tmp/postgresql.conf
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
# ****************** Recovery config 12, 13, 14 **************************
touch $PGDATA/recovery.signal

# setup postgresql.conf
touch /tmp/postgresql.conf
echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/postgresql.conf
#echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
if [[ "${PITR_TIME:-0}" != "latest" ]]; then
echo "recovery_target_time = '$PITR_TIME'" >>/tmp/postgresql.conf
else
echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf
fi
echo "recovery_target_action = 'promote'" >>/tmp/postgresql.conf
echo "wal_level = replica" >>/tmp/postgresql.conf
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

echo "wal_keep_size = 64" >>/tmp/postgresql.conf
echo "hot_standby = on" >>/tmp/postgresql.conf
echo "wal_log_hints = on" >>/tmp/postgresql.conf
echo "wal_keep_size = 64" >>/tmp/postgresql.conf
echo "hot_standby = on" >>/tmp/postgresql.conf
echo "wal_log_hints = on" >>/tmp/postgresql.conf

fi

# ****************** Recovery config 12 **************************
# 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.
Expand Down

0 comments on commit 75d90dc

Please sign in to comment.