<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Migration Between Releases</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 8.0.11 Documentation" HREF="index.html"><LINK REL="UP" TITLE="Backup and Restore" HREF="backup.html"><LINK REL="PREVIOUS" TITLE="On-line backup and point-in-time recovery (PITR)" HREF="backup-online.html"><LINK REL="NEXT" TITLE="Monitoring Database Activity" HREF="monitoring.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2007-02-02T03:57:22"></HEAD ><BODY CLASS="SECT1" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" >PostgreSQL 8.0.11 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="backup-online.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="backup.html" >Fast Backward</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" >Chapter 22. Backup and Restore</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="backup.html" >Fast Forward</A ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="monitoring.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="MIGRATION" >22.4. Migration Between Releases</A ></H1 ><A NAME="AEN21753" ></A ><A NAME="AEN21755" ></A ><P > This section discusses how to migrate your database data from one <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > release to a newer one. The software installation procedure <I CLASS="FOREIGNPHRASE" >per se</I > is not the subject of this section; those details are in <A HREF="installation.html" >Chapter 14</A >. </P ><P > As a general rule, the internal data storage format is subject to change between major releases of <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > (where the number after the first dot changes). This does not apply to different minor releases under the same major release (where the number after the second dot changes); these always have compatible storage formats. For example, releases 7.0.1, 7.1.2, and 7.2 are not compatible, whereas 7.1.1 and 7.1.2 are. When you update between compatible versions, you can simply replace the executables and reuse the data directory on disk. Otherwise you need to back up your data and restore it on the new server. This has to be done using <SPAN CLASS="APPLICATION" >pg_dump</SPAN >; file system level backup methods obviously won't work. There are checks in place that prevent you from using a data directory with an incompatible version of <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN >, so no great harm can be done by trying to start the wrong server version on a data directory. </P ><P > It is recommended that you use the <SPAN CLASS="APPLICATION" >pg_dump</SPAN > and <SPAN CLASS="APPLICATION" >pg_dumpall</SPAN > programs from the newer version of <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN >, to take advantage of any enhancements that may have been made in these programs. Current releases of the dump programs can read data from any server version back to 7.0. </P ><P > The least downtime can be achieved by installing the new server in a different directory and running both the old and the new servers in parallel, on different ports. Then you can use something like </P><PRE CLASS="PROGRAMLISTING" >pg_dumpall -p 5432 | psql -d template1 -p 6543</PRE ><P> to transfer your data. Or use an intermediate file if you want. Then you can shut down the old server and start the new server at the port the old one was running at. You should make sure that the old database is not updated after you run <SPAN CLASS="APPLICATION" >pg_dumpall</SPAN >, otherwise you will obviously lose that data. See <A HREF="client-authentication.html" >Chapter 19</A > for information on how to prohibit access. </P ><P > In practice you probably want to test your client applications on the new setup before switching over completely. This is another reason for setting up concurrent installations of old and new versions. </P ><P > If you cannot or do not want to run two servers in parallel you can do the backup step before installing the new version, bring down the server, move the old version out of the way, install the new version, start the new server, restore the data. For example: </P><PRE CLASS="PROGRAMLISTING" >pg_dumpall > backup pg_ctl stop mv /usr/local/pgsql /usr/local/pgsql.old cd ~/postgresql-8.0.11 gmake install initdb -D /usr/local/pgsql/data postmaster -D /usr/local/pgsql/data psql -f backup template1</PRE ><P> See <A HREF="runtime.html" >Chapter 16</A > about ways to start and stop the server and other details. The installation instructions will advise you of strategic places to perform these steps. </P ><DIV CLASS="NOTE" ><BLOCKQUOTE CLASS="NOTE" ><P ><B >Note: </B > When you <SPAN CLASS="QUOTE" >"move the old installation out of the way"</SPAN > it may no longer be perfectly usable. Some of the executable programs contain absolute paths to various installed programs and data files. This is usually not a big problem but if you plan on using two installations in parallel for a while you should assign them different installation directories at build time. (This problem is rectified in <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > 8.0 and later, but you need to be wary of moving older installations.) </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="backup-online.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="monitoring.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >On-line backup and point-in-time recovery (PITR)</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="backup.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Monitoring Database Activity</TD ></TR ></TABLE ></DIV ></BODY ></HTML >