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.

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

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/ --encoding UTF8 --locale=C -D /Library/Server/PostgreSQL/Data
sudo -u _postgres /Applications/ -b /Applications/ -B /Applications/ -d /Library/Server/PostgreSQL/DataOld -D /Library/Server/PostgreSQL/Data
sudo launchctl load -w /Applications/
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: