HowTo: Upgrade Versions 8.* versions

Because of the way that PostgreSQL manages it's databases, the 'upgrade' process is slightly more painful than it could be, and is really not well suited to an automatic upgrade process.  For that reason, the following process is the process we use internally. Anytime a PostgreSQL server changes revisions, for example form 8.2 to 8.3, the database has to be reinitialized.  Minor revisions do not require this and can be upgraded without this process.  

1. Backup the current databases. 

In Terminal dump the current databases to a disk file for restore using the following command:

	sudo bash
	su postgres
	/Library/PostgreSQL8/bin/pg_dumpall -h localhost -f ~/full_backup.sql

2. Move the current Library/PostgreSQL8 folder for recovery if required.

In Terminal move the current PostgreSQL folder to an alternate name using the following command:

	sudo mv /Library/PostgreSQL8 /Library/PostgreSQL8_PreUpgrade

3. Install the new version of PostgreSQL8.

4. Restore the backups.

In Terminal dump the current databases to a disk file for restore using the following command:

	sudo bash
	su postgres
	/Library/PostgreSQL8/bin/psql -h localhost -f ~/full_backup.sql

5. Test the database.

6. Assuming successful tests, delete the old PostgreSQL8 folder.

	sudo rm -rf /Library/PostgreSQL8_PreUpgrade

At this point, the upgrade is complete, and you can safely delete the file full_backup.sql from your home directory