]> granicus.if.org Git - postgresql/commitdiff
Update permissions?
authorBruce Momjian <bruce@momjian.us>
Mon, 14 Jan 2002 22:54:44 +0000 (22:54 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 14 Jan 2002 22:54:44 +0000 (22:54 +0000)
contrib/pg_upgrade/README
contrib/pg_upgrade/pg_upgrade
contrib/pg_upgrade/pg_upgrade.man

index 3844735e6464183146bffc106c387e9cc023f6de..f5fb65e7d4f5fd9fc18a11fd816fab0bdf42e647 100644 (file)
@@ -12,21 +12,21 @@ S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
        data
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
-       pg_upgrade is a utility  for  upgrading  from  a  previous
+       p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be is a utility  for  upgrading  from  a  previous
        PostgreSQL release without reloading all the data. Not all
-       PostgreSQL releases can be handled this  way.   Check  the
+       PostgreSQL releases  can  use  this  utility.   Check  the
        release notes for details about your version.
 
-       pg_upgrade  must  be  run in two stages.  In phase one you
-       must run pg_upgrade with your old database installation in
-       place.   In phase two, pg_upgrade must be run on a freshly
-       initdb'ed current  install.   In  both  phases,  the  same
-       pg_upgrade  script  matching  the  newly installed version
+       p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be  must  be  run in two stages.  In phase one you
+       must run p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be with your old database installation in
+       place.   In phase two, p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be must be run on a freshly
+       i\bin\bni\bit\btd\bdb\bb'ed current  install.   In  both  phases,  the  same
+       p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be  script  matching  the  newly installed version
        must be used.
 
 U\bUp\bpg\bgr\bra\bad\bdi\bin\bng\bg P\bPo\bos\bst\btg\bgr\bre\beS\bSQ\bQL\bL w\bwi\bit\bth\bh p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be
        1) Back up your existing  data  directory,  preferably  by
-       making a complete dump with pg_dumpall.
+       making a complete dump with p\bpg\bg_\b_d\bdu\bum\bmp\bpa\bal\bll\bl.\b.
 
        2)  Copy  the  program _\bp_\bg_\bs_\bq_\bl_\b/_\bc_\bo_\bn_\bt_\br_\bi_\bb_\b/_\bp_\bg_\b__\bu_\bp_\bg_\br_\ba_\bd_\be_\b/_\bp_\bg_\b__\bu_\bp_\bg_\br_\ba_\bd_\be
        from the current PostgreSQL  distribution  somewhere  into
@@ -52,7 +52,7 @@ U\bUp\bpg\bgr\bra\bad\bdi\bin\bng\bg P\bPo\bos\bst\btg\bgr\bre\beS\bSQ\bQL\bL w\bwi\bit\bth\bh p\bpg\bg_\b
        $\b$ m\bma\bak\bke\be i\bin\bns\bst\bta\bal\bll\bl
 
        to  install  the  _\bp_\bg_\b__\br_\be_\bs_\be_\bt_\bx_\bl_\bo_\bg  utility which is needed by
-       pg_upgrade.
+       p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be.
 
        6) Run initdb to create a new template1 database  contain-
        ing  the system tables for the new release.  Make sure you
@@ -76,7 +76,7 @@ PG_UPGRADE(1)     PostgreSQL Client Applications    PG_UPGRADE(1)
        alter pg_hba.conf temporarily.)
 
        8)  Change your working directory to the pgsql main direc-
-       tory, and type:
+       tory again, and type:
 
        $\b$ p\bpg\bg_\b_u\bup\bpg\bgr\bra\bad\bde\be -\b-2\b2
 
@@ -92,12 +92,13 @@ PG_UPGRADE(1)     PostgreSQL Client Applications    PG_UPGRADE(1)
 
        10)   Carefully  examine  the  contents  of  the  upgraded
        databases.  If you detect problems, you'll need to recover
-       by restoring from your full pg_dump backup. You can delete
-       the _\bp_\bg_\b__\bu_\bp_\bg_\br_\ba_\bd_\be_\b__\bi_\bn_\bf_\bo_\b/ directory when you are satisfied.
+       by restoring from your full  p\bpg\bg_\b_d\bdu\bum\bmp\bpa\bal\bll\bl  backup.  You  can
+       delete  the _\bp_\bg_\b__\bu_\bp_\bg_\br_\ba_\bd_\be_\b__\bi_\bn_\bf_\bo_\b/ directory when you are satis-
+       fied.
 
-       The  upgraded  databases  will be in an un-vacuumed state.
-       You will probably want to  run  a  _\bV_\bA_\bC_\bU_\bU_\bM  _\bA_\bN_\bA_\bL_\bY_\bZ_\bE  b\bbe\bef\bfo\bor\bre\be
-       b\bbe\beg\bgi\bin\bnn\bni\bin\bng\bg p\bpr\bro\bod\bdu\buc\bct\bti\bio\bon\bn w\bwo\bor\brk\bk.\b.
+       The upgraded databases will be in  an  un-vacuumed  state.
+       You  will  probably  want  to  run a _\bV_\bA_\bC_\bU_\bU_\bM _\bA_\bN_\bA_\bL_\bY_\bZ_\bE before
+       beginning production work.
 
 S\bSE\bEE\bE A\bAL\bLS\bSO\bO
        initdb(1), postmaster(1), pg_dump(1), pg_dumpall(1), vacu-
@@ -124,7 +125,6 @@ S\bSE\bEE\bE A\bAL\bLS\bSO\bO
 
 
 
-
 
 
 14 Jan 2002               PG_UPGRADE(1)                         2
index 61916f37d62b83cefe288ef245e1a31d000ee27e..939bf0ed80d57ee5148d64a9bcca1b97ff78aa39 100755 (executable)
@@ -3,7 +3,7 @@
 # pg_upgrade: update a database without needing a full dump/reload cycle.
 # CAUTION: Read the manual page before trying to use this!
 
-# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.1 2002/01/14 17:32:07 momjian Exp $
+# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.2 2002/01/14 22:54:44 momjian Exp $
 #
 # NOTE: we must be sure to update the version-checking code a few dozen lines
 # below for each new PostgreSQL release.
@@ -30,6 +30,7 @@ CUR_VERSION="7.2"
 trap "rm -f /tmp/$$.*" 0 1 2 3 15
 
 PHASE=""
+
 if [ "$#" -eq 1 ]
 then
        if [ "X$1" = "X-1" ]
@@ -38,26 +39,41 @@ then
        elif [ "X$1" = "X-2" ]
        then    PHASE="2"
                shift
+       elif [ "X$1" = "X-D" ]
+       then    DATADIR="$2"
+               shift
        fi
 fi
 
 if [ "$PHASE" = "" ]
 then   echo "You must run $0 in either mode 1 or mode 2." 1>&2
-       echo "Usage:  $0 [ -1 | -2 ]" 1>&2
+       echo "Usage:  $0 [-D datadir] -1 | -2" 1>&2
+       exit 1
+fi
+
+if [ "$DATADIR" = "" ]
+then   echo "You must set the DATADIR environment variable or specify it with -D." 1>&2
+       echo "Usage:  $0 [-D datadir] -1 | -2" 1>&2
        exit 1
 fi
 
-if [ ! -e data ]
-then   echo "$0 must be run from the directory above your /data directory.
+if [ ! -d "$DATADIR" ]
+then   echo "$DATADIR does not exist.
 $0 aborted." 1>&2
        if [ "$PHASE" -eq 2 ]
-       then    echo "You must run initdb to create a template1 database." 1>&2
+       then    echo "Perhaps you didn't run initdb." 1>&2
        fi
        exit 1
 fi
 
+if [ "$USER" = "root" -o ! -r "$DATADIR"/PG_VERSION ]
+then   echo "You must run this as the PostgreSQL superuser.
+$0 aborted." 1>&2
+       exit 1
+fi
+
 INFODIR="pg_upgrade_info"
-OLDDIR="$INFODIR/data"
+SAVEDATA="$INFODIR"/"`basename \"$DATADIR\"`"
 
 make_dbobjoidmap()
 {
@@ -99,13 +115,15 @@ move_objfiles()
 {
        # Test to make sure there is a matching file in each place
 
-       if [ ! -e "$OLDDIR"/base/"$SRC_DBOID"/"$SRC_OID" ]
+       if [ ! -f "$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID" -a \
+            ! -h "$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID" ]
        then    echo "Move of database $DB, OID $SRC_OID, object $OBJ failed.
 File not found;  exiting" 1>&2
                exit 1
        fi
 
-       if [ ! -e data/base/"$DST_DBOID"/"$DST_OID" ]
+       if [ ! -f "$DATADIR"/base/"$DST_DBOID"/"$DST_OID" -a \
+            ! -h "$DATADIR"/base/"$DST_DBOID"/"$DST_OID" ]
        then    echo "Move of database $DB, OID $DST_OID, object $OBJ failed.
 File not found;  exiting" 1>&2
                exit 1
@@ -113,7 +131,7 @@ File not found;  exiting" 1>&2
 
        # Move files
 
-       mv -f "$OLDDIR"/base/"$SRC_DBOID"/"$SRC_OID" data/base/"$DST_DBOID"/"$DST_OID"
+       mv -f "$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID" "$DATADIR"/base/"$DST_DBOID"/"$DST_OID"
        if [ "$?" -ne 0 ]
        then    echo "Move of database $DB, OID $SRC_OID, object $OBJ
 to $DST_OID failed.;  exiting" 1>&2
@@ -122,10 +140,10 @@ to $DST_OID failed.;  exiting" 1>&2
 
        # handle table extents
 
-       ls "$OLDDIR"/base/"$SRC_DBOID"/"$SRC_OID".* 2>/dev/null | while read FILE
+       ls "$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID".* 2>/dev/null | while read FILE
        do
                EXT=`basename "$FILE" | sed 's/^.*\.\(.*\)$/\1/'`
-               mv -f "$FILE" data/base/"$DST_DBOID"/"$DST_OID"."$EXT"
+               mv -f "$FILE" "$DATADIR"/base/"$DST_DBOID"/"$DST_OID"."$EXT"
                if [ "$?" -ne 0 ]
                then    echo "Move of database $DB, OID $SRC_OID, object $OBJ
 to $DST_OID failed.;  exiting" 1>&2
@@ -142,15 +160,15 @@ then
        ##########################
 
 
-       if [ ! -d data/base/1 ]
-       then    echo "There is no database template1 in data/base." 1>&2
+       if [ ! -d "$DATADIR"/base/1 ]
+       then    echo "There is no database template1 in $DATADIR/base." 1>&2
                exit 1
        fi
 
        # get version
-       SRC_VERSION="`cat data/PG_VERSION`"
+       SRC_VERSION=`cat "$DATADIR"/PG_VERSION`
        if [ "$SRC_VERSION" = "" ]
-       then    echo "$0 can not find PostgreSQL version file 'data/PG_VERSION'.
+       then    echo "$0 can not find PostgreSQL version file '$DATADIR/PG_VERSION'.
 $0 aborted." 1>&2
                exit 1
        fi
@@ -258,9 +276,9 @@ $0 aborted." 1>&2
                exit 1
        fi
 
-       mv data "$INFODIR"
+       mv "$DATADIR" "$INFODIR"
        if [ $? -ne 0 ]
-       then    echo "Can not move old /data out of the way.
+       then    echo "Can not move old /$DATADIR out of the way.
 $0 aborted." 1>&2
                exit 1
        fi
@@ -283,38 +301,38 @@ then      echo "There is no '$INFODIR' directory from a phase 1 run of $0." 1>&2
        exit 1  
 fi
 
-if [ ! -e "$OLDDIR" ]
-then   echo "There is no '$OLDDIR' directory from the phase 1 run of $0." 1>&2
+if [ ! -d "$SAVEDATA" ]
+then   echo "There is no '$SAVEDATA' directory from the phase 1 run of $0." 1>&2
        exit 1  
 fi
 
-if [ ! -f "$OLDDIR/PG_VERSION" ]
-then   echo "Cannot read '$OLDDIR/PG_VERSION' --- something is wrong." 1>&2
+if [ ! -f "$SAVEDATA/PG_VERSION" ]
+then   echo "Cannot read '$SAVEDATA/PG_VERSION' --- something is wrong." 1>&2
        exit 1
 fi
 
-if [ ! -f "data/PG_VERSION" ]
-then   echo "Cannot read 'data/PG_VERSION' --- something is wrong." 1>&2
+if [ ! -f "$DATADIR/PG_VERSION" ]
+then   echo "Cannot read '$DATADIR/PG_VERSION' --- something is wrong." 1>&2
        exit 1
 fi
 
-if [ ! -d "data/base/1" ]
-then   echo "Cannot find database template1 in 'data/base'." 1>&2
+if [ ! -d "$DATADIR/base/1" ]
+then   echo "Cannot find database template1 in '$DATADIR/base'." 1>&2
        echo "Are you running $0 as the postgres superuser?" 1>&2
        exit 1
 fi
 
 # Get the actual versions seen in the data dirs.
 
-SRC_VERSION=`cat "$OLDDIR"/PG_VERSION`
-DST_VERSION=`cat data/PG_VERSION`
+SRC_VERSION=`cat "$SAVEDATA"/PG_VERSION`
+DST_VERSION=`cat "$DATADIR"/PG_VERSION`
 
 # Check for version compatibility.
 # This code will need to be updated/reviewed for each new PostgreSQL release.
 
 if [ "$DST_VERSION" != "$CUR_VERSION" ]
 then   echo "$0 is for PostgreSQL version $CUR_VERSION
-but data/PG_VERSION contains $DST_VERSION." 1>&2
+but $DATADIR/PG_VERSION contains $DST_VERSION." 1>&2
        echo "Did you run initdb for version $UPGRADE_VERSION by mistake?" 1>&2
        exit 1
 fi
@@ -349,17 +367,17 @@ fi
 # If the XID is > 2 billion, 7.1 database will have non-frozen XID's in 
 # low numbers, and 7.2 will think they are in the future --- bad.
 
-SRC_XID=`pg_resetxlog -n "$OLDDIR" | grep "NextXID" | awk -F'  *' '{print $4}'`
+SRC_XID=`pg_resetxlog -n "$SAVEDATA" | grep "NextXID" | awk -F'  *' '{print $4}'`
 if [ "$SRC_VERSION" = "7.1" -a "$SRC_XID" -gt 2000000000 ]
 then   echo "XID too high for $0.;  exiting" 1>&2
        exit 1
 fi
-DST_XID=`pg_resetxlog -n data | grep "NextXID" | awk -F'  *' '{print $4}'`
+DST_XID=`pg_resetxlog -n "$DATADIR" | grep "NextXID" | awk -F'  *' '{print $4}'`
 
 # compare locales to make sure they match
 
-pg_resetxlog -n "$OLDDIR" | grep "^LC_" > /tmp/$$.0
-pg_resetxlog -n data | grep "^LC_" > /tmp/$$.1
+pg_resetxlog -n "$SAVEDATA" | grep "^LC_" > /tmp/$$.0
+pg_resetxlog -n "$DATADIR" | grep "^LC_" > /tmp/$$.1
 if ! diff /tmp/$$.0 /tmp/$$.1 >/dev/null
 then   echo "Locales do not match between the two versions.;  exiting" 1>&2
        exit 1
@@ -470,7 +488,7 @@ then        MAX_XID="$SRC_XID"
 else   MAX_XID="$DST_XID"
 fi
 
-pg_resetxlog -x "$MAX_XID" data
+pg_resetxlog -x "$MAX_XID" "$DATADIR"
 if [ "$?" -ne 0 ]
 then   echo "Unable to set new XID.;  exiting" 1>&2
        exit 1
@@ -478,18 +496,18 @@ fi
 
 # Move over old WAL
 
-rm -r data/pg_xlog
-mv -f "$OLDDIR"/pg_xlog data
+rm -r "$DATADIR"/pg_xlog
+mv -f "$SAVEDATA"/pg_xlog "$DATADIR"
 
 # Set last log file id and segment from old database
 
-LOG_ID=`pg_resetxlog -n "$OLDDIR" | grep "Current log file id:" |
+LOG_ID=`pg_resetxlog -n "$SAVEDATA" | grep "Current log file id:" |
        awk -F'  *' '{print $5}'`
 if [ "$LOG_ID" = "" ]
 then   echo "Unable to get old log file id.;  exiting" 1>&2
        exit 1
 fi
-SEG_ID=`pg_resetxlog -n "$OLDDIR" | grep "Next log file segment:" |
+SEG_ID=`pg_resetxlog -n "$SAVEDATA" | grep "Next log file segment:" |
        awk -F'  *' '{print $5}'`
 if [ "$SEG_ID" = "" ]
 then   echo "Unable to get old log segment id.;  exiting" 1>&2
@@ -498,7 +516,7 @@ fi
 
 # Set checkpoint location of new database
 
-pg_resetxlog -l "$LOG_ID" "$SEG_ID" data
+pg_resetxlog -l "$LOG_ID" "$SEG_ID" "$DATADIR"
 if [ "$?" -ne 0 ]
 then   echo "Unable to set new log file/segment id.;  exiting" 1>&2
        exit 1
index 82914b388faa67584fafed6d94c1f0994e520457..f4b28d15b9ea1021f9b0664754d18ed13f2b2afd 100644 (file)
@@ -1,23 +1,23 @@
 .TH PG_UPGRADE 1 "PG_UPGRADE(1)" "14 Jan 2002" "PostgreSQL Client Applications" ""
 .SH NAME
-pg_upgrade \- upgrade tool
+pg_upgrade \- upgrading from a previous release without reloading
 .SH SYNOPSIS
-Allows upgrading from a previous release without reloading data
+pg_upgrade [-D \fIdata_dir\fP] -1 | -2
 .SH DESCRIPTION
-pg_upgrade is a utility for upgrading from a previous PostgreSQL release
-without reloading all the data. Not all PostgreSQL releases can be
-handled this way.  Check the release notes for details about your
+\fBpg_upgrade\fP is a utility for upgrading from a previous PostgreSQL release
+without reloading all the data. Not all PostgreSQL releases can use
+this utility.  Check the release notes for details about your
 version.
 .LP
-pg_upgrade must be run in two stages.  In phase one you must run
-pg_upgrade with your old database installation in place.  In phase two, 
-pg_upgrade must be run on a freshly initdb'ed current install. 
-In both phases, the same pg_upgrade script matching the newly installed
+\fBpg_upgrade\fP must be run in two stages.  In phase one you must run
+\fBpg_upgrade\fP with your old database installation in place.  In phase two, 
+\fBpg_upgrade\fP must be run on a freshly \fBinitdb\fP'ed current install. 
+In both phases, the same \fBpg_upgrade\fP script matching the newly installed
 version must be used.
 .SH Upgrading PostgreSQL with pg_upgrade
 .LP
 1) Back up your existing data directory, preferably by making a complete
-dump with pg_dumpall.
+dump with \fBpg_dumpall.\fP
 .LP
 2) Copy the program \fIpgsql/contrib/pg_upgrade/pg_upgrade\fP from the current
 PostgreSQL distribution somewhere into your path.
@@ -27,6 +27,7 @@ PostgreSQL distribution somewhere into your path.
 .B $ pg_upgrade -1
 .sp
 to collect information about the old database needed for the upgrade.
+You may use \fI-D\fP to specify the data directory, or use PGDATA.
 .LP
 4) Do:
 .LP
@@ -41,7 +42,7 @@ to install the new binaries.
 .B $ make install
 .sp
 to install the \fIpg_resetxlog\fP utility which is needed by
-pg_upgrade.
+\fBpg_upgrade\fP.
 .LP
 6) Run initdb to create a new template1 database containing the system
 tables for the new release.  Make sure you use settings similar to those
@@ -51,7 +52,7 @@ used in your previous version.
 to the server until the upgrade is complete.  You may wish to start the
 postmaster without -i or alter pg_hba.conf temporarily.)
 .LP
-8)  Change your working directory to the pgsql main directory, and type: 
+8)  Change your working directory to the pgsql main directory again, and type: 
 .LP
 .B $ pg_upgrade -2
 .sp
@@ -66,10 +67,10 @@ subdirectories.
 .LP
 10)  Carefully examine the contents of the upgraded databases.  If you
 detect problems, you'll need to recover by restoring from your full
-pg_dump backup. You can delete the \fIpg_upgrade_info/\fP directory when you
+\fBpg_dumpall\fP backup. You can delete the \fIpg_upgrade_info/\fP directory when you
 are satisfied.
 .LP
 The upgraded databases will be in an un-vacuumed state.  You will
-probably want to run a \fIVACUUM ANALYZE\fB before beginning production work.
+probably want to run a \fIVACUUM ANALYZE\fP before beginning production work.
 .SH SEE ALSO
 initdb(1), postmaster(1), pg_dump(1), pg_dumpall(1), vacuumdb(1)