Next: pgaccess
Up: Reference Manual
Previous: pg_passwd
Subsections
pg_upgrade
pg_upgrade -- Allows upgrade from a previous release without reloading
data
pg_upgrade [ -f filename ] old_data_dir
pg_upgrade is a utility for upgrading from a previous Postgres release
without reloading all the data. Not all Postgres release transitions
can be handled this way. Check the release notes for details on your
installation.
- 1.
- Back up your existing data directory, preferably by making a complete
dump with pg_dumpall.
- 2.
- Then do:
$ pg_dumpall -s > db.out
- 3.
- to dump out your old database's table definitions without any data.
- 4.
- Stop the old postmaster and all backends.
- 5.
- Rename (using mv) your old pgsql data/ directory to data.old/.
- 6.
- Do:
$ make install
- 7.
- to install the new binaries.
- 8.
- Run initdb to create a new template1 database containing the system
tables for the new release.
- 9.
- Start the new postmaster. (Note: it is critical that no users connect
to the database until the upgrade is complete. You may wish to start
the postmaster without -i and/or alter pg_hba.conf temporarily.)
- 10.
- Change your working directory to the pgsql main directory, and type:
$ pg_upgrade -f db.out data.old
- 11.
- The program will do some checking to make sure everything is properly
configured, and will run your db.out script to recreate all the databases
and tables you had, but with no data. It will then physically move
the data files containing non-system tables and indexes from data.old/
into the proper data/ subdirectories, replacing the empty data files
created during the db.out script.
- 12.
- Restore your old pg_hba.conf if needed to allow user logins.
- 13.
- Stop and restart the postmaster.
- 14.
- Carefully examine the contents of the upgraded database. If
you detect problems, you'll need to recover by restoring from your
full pg_dump backup. You can delete the data.old/ directory when
you are satisfied.
- 15.
- The upgraded database will be in an un-vacuumed state. You will probably
want to run a VACUUM ANALYZE before beginning production
work.
Next: pgaccess
Up: Reference Manual
Previous: pg_passwd
Bruce Momjian
2005-04-21