Skip to content
Snippets Groups Projects
Verified Commit 3eb83541 authored by Evangelos Foutras's avatar Evangelos Foutras :smiley_cat:
Browse files

postgres: keep root ownership of /var/lib/postgres

Adapt upgrade_pg.sh to avoid manipulating /var/lib/postgres' structure
as the postgres user. Instead, create a new empty data directory owned
by postgres for initdb to use.
parent 58c8c86e
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,8 @@ if [[ -d /var/lib/postgres/data-$FROM_VERSION ]]; then
exit 3
fi
pacman -S --needed postgresql-old-upgrade
# mask postgresql.service to make sure that other services with
# Wants=postgresql.service and Restart=on-failure will not start
# it again during the upgrade
......@@ -37,11 +39,12 @@ systemctl mask postgresql.service
systemctl daemon-reload
systemctl stop postgresql.service
pacman -S --needed postgresql-old-upgrade
chown postgres:postgres /var/lib/postgres/
su - postgres -c "mv /var/lib/postgres/data /var/lib/postgres/data-$FROM_VERSION"
su - postgres -c 'mkdir /var/lib/postgres/data'
su - postgres -c 'chattr -f +C /var/lib/postgres/data' || :
# rename the old cluster and create a new empty 'data' directory for initdb
mv /var/lib/postgres/{data,data-$FROM_VERSION}
mkdir /var/lib/postgres/data
chown postgres: /var/lib/postgres/data
chattr -f +C /var/lib/postgres/data || :
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'
vimdiff /var/lib/postgres/{data,data-$FROM_VERSION}/pg_hba.conf
vimdiff /var/lib/postgres/{data,data-$FROM_VERSION}/postgresql.conf
......@@ -53,7 +56,9 @@ for f in {fullchain,chain,privkey}.pem; do
fi
done
su - postgres -c "pg_upgrade -b /opt/pgsql-$FROM_VERSION/bin/ -B /usr/bin/ \
# running pg_upgrade from /tmp so it can create pg_upgrade_internal.log
su - postgres -c "cd /tmp && \
pg_upgrade -b /opt/pgsql-$FROM_VERSION/bin/ -B /usr/bin/ \
-d /var/lib/postgres/data-$FROM_VERSION -D /var/lib/postgres/data"
# unmask and start postgresql.service
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment