OS X Server 3.2.1 update breaks PostgreSQL

22nd Sep 2014

The OS X Server 3.2.1 just released appears to break PostgreSQL during the update process. The new version of Postgresql installed (9.3.x over 9.2.x) contains an updated configuration field: “unix_socket_directory” becomes “unix_socket_directories”, the value doesn’t change, just the name.

The installer also appears to fail while upgrading the PostgreSQL data, causing the process to crash.

Thanks to the helpful users on the Apple Discussion boards here a fix has been found. As always, back up before you change anything!

To resolve the issue first stop the postgres service (2 commands) :

sudo su
serveradmin stop postgres

Update the configuration field (1 command) :

pico /Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist
replace unix_socket_directory with unix_socket_directories
save & exit

Move the PostgreSQL data folder (1 command) :

mv /Library/Server/PostgreSQL/Data /Library/Server/PostgreSQL/DataOld

Recreate the standard PostgreSQL Data folder and initialise a blank database (1 command) :

sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/initdb /Library/Server/PostgreSQL/Data -E utf8 --lc-collate=C --lc-ctype=C

Update the data in the blank database with data from the DataOld folder (1 command) :

sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/pg_upgrade -b /Applications/Server.app/Contents/ServerRoot/usr/libexec/postgresql9.2 -B /Applications/Server.app/Contents/ServerRoot/usr/bin -d /Library/Server/PostgreSQL/DataOld -D /Library/Server/PostgreSQL/Data

Restart the PostgreSQL service (2 commands) :

launchctl load -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/org.postgresql.postgres.plist
serveradmin start postgres