Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ansible/files/admin_api_scripts/pg_upgrade_initiate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cleanup() {

if [ -d "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" ]; then
echo "Copying pg_upgrade output to /var/log"
cp -R "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" /var/log/
cp -R "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" /var/log/ || true
fi

if [ -L /var/lib/postgresql ]; then
Expand Down Expand Up @@ -136,6 +136,7 @@ function initiate_upgrade {
if [[ "$OLD_PGVERSION" =~ 14* ]]; then
SHARED_PRELOAD_LIBRARIES=$(echo "$SHARED_PRELOAD_LIBRARIES" | sed "s/wrappers, //")
fi
SHARED_PRELOAD_LIBRARIES=$(echo "$SHARED_PRELOAD_LIBRARIES" | sed "s/pg_cron, //")

PGDATAOLD=$(cat /etc/postgresql/postgresql.conf | grep data_directory | sed "s/data_directory = '\(.*\)'.*/\1/")

Expand Down Expand Up @@ -165,7 +166,7 @@ function initiate_upgrade {
# Make latest libpq available to pg_upgrade
mkdir -p /usr/lib/postgresql/lib/aarch64
if [ ! -L /usr/lib/postgresql/lib/aarch64/libpq.so.5 ]; then
ln -s "$PGLIBNEW/libpq.so.5" /usr/lib/postgresql/lib/aarch64/libpq.so.5
ln -s "$PGLIBNEW/libpq.so.5" /usr/lib/postgresql/lib/aarch64/libpq.so.5
fi

# upgrade job outputs a log in the cwd; needs write permissions
Expand Down Expand Up @@ -223,6 +224,7 @@ function initiate_upgrade {
--new-datadir=${PGDATANEW} \
--jobs="${WORKERS}" \
--old-options='-c config_file=/etc/postgresql/postgresql.conf' \
--old-options="-c shared_preload_libraries='${SHARED_PRELOAD_LIBRARIES}'" \
--new-options="-c data_directory=${PGDATANEW}" \
--new-options="-c shared_preload_libraries='${SHARED_PRELOAD_LIBRARIES}'"
EOF
Expand All @@ -240,6 +242,10 @@ EOF
fi
ln -s /var/lib/postgresql.bak/data /var/lib/postgresql/data
fi

if [ ! -L /var/lib/postgresql/data ]; then
ln -s /data/pgdata /var/lib/postgresql/data
fi

echo "9. Stopping postgres; running pg_upgrade"
systemctl stop postgresql
Expand Down