Skip to content

Instantly share code, notes, and snippets.

@juno
Last active December 28, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juno/7542242 to your computer and use it in GitHub Desktop.
Save juno/7542242 to your computer and use it in GitHub Desktop.
Updating databases from Postgres.app 9.2 to Postgres.app 9.3. http://postgresapp.com/

Beware: Postgres.app 9.3 has changed it's application name and prefix for database directory path.

Step 1

Install and launch Postgres93.app. It initialize database.

Then, quit Postgres93.app.

Step 2

$ /Applications/Postgres93.app/Contents/MacOS/bin/pg_upgrade \
  -b /Applications/Postgres.app/Contents/MacOS/bin \
  -B /Applications/Postgres93.app/Contents/MacOS/bin \
  -d ~/Library/Application\ Support/Postgres/var \
  -D ~/Library/Application\ Support/Postgres93/var

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is a superuser                       ok
Checking for prepared transactions                          ok
Checking for reg* system OID user data types                ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok
Checking for presence of required libraries                 ok
Checking database user is a superuser                       ok
Checking for prepared transactions                          ok

If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.

Performing Upgrade
------------------
Analyzing all rows in the new cluster                       ok
Freezing all rows on the new cluster                        ok
Deleting files from new pg_clog                             ok
Copying old pg_clog to new server                           ok
Setting next transaction ID for new cluster                 ok
Setting oldest multixact ID on new cluster                  ok
Resetting WAL archives                                      ok
Setting frozenxid counters in new cluster                   ok
Restoring global objects in the new cluster                 ok
Adding support functions to new cluster                     ok
Restoring database schemas in the new cluster
                                                            ok
Removing support functions from new cluster                 ok
Copying user relation files
                                                            ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to analyze new cluster                      ok
Creating script to delete old cluster                       ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
    analyze_new_cluster.sh

Running this script will delete the old cluster's data files:
    delete_old_cluster.sh

Step 3

Launch Postgres93.app.

$ ./analyze_new_cluster.sh

Step 4

$ ./delete_old_cluster.sh

Then, uninstall old Postgres.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment