This article has been archived and is no longer updated by Apple.

Recovering custom Postgres data after upgrading to OS X Server v3.2.1 or later

OS X Server uses a Postgres database to store service data. If you’ve added your own tables to the database, your Postgres data might not be accessible after updating to Server v3.2.1 or later.

If you find that your Postgres data is inaccessible after upgrading, you can use these steps.

  1. Log into your server as an administrator.

  2. Open Terminal and use the following command.

    sudo serveradmin stop postgres

  3. Edit /Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist and change unix_socket_directory to unix_socket_directories.

  4. Use the following commands in Terminal:

cd /tmp

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

sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/initdb --encoding UTF8 --locale=C -D /Library/Server/PostgreSQL/Data

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

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

sudo serveradmin start postgres

Once you’ve made sure that all of your data was successfully migrated, you can remove /Library/Server/PostgreSQL/DataOld.

Note: The Postgres database used by OS X Server is only intended for use with service data used by the system. Avoid adding custom content to this database. If you’d like to run Postgres on your OS X Server, you should download and install your own instance.

Published Date: