Browse Source

fix pg_migrate and for those running 7.3 (with the broken pg_migrate) tell them how to dump and restore manually

Ralf S. Engelschall 22 years ago
parent
commit
e786b6df5f
2 changed files with 23 additions and 2 deletions
  1. 14 1
      postgresql/pg_migrate
  2. 9 1
      postgresql/postgresql.spec

+ 14 - 1
postgresql/pg_migrate

@@ -36,6 +36,14 @@ LC_CTYPE=C
 export LC_CTYPE
 export LC_CTYPE
 umask 022
 umask 022
 
 
+#   check command line
+if [ $# -ne 1 ]; then
+    echo "$0:ERROR: invalid command line" 1>&2
+    echo "$0:USAGE: $0 dump|restore" 1>&2
+    exit 1
+fi
+
+#   dispatch into commands
 cmd="$1"
 cmd="$1"
 shift
 shift
 case $cmd in
 case $cmd in
@@ -78,8 +86,9 @@ case $cmd in
         done
         done
 
 
         echo "++ dumping all databases into $l_prefix/var/postgresql/db.dump.sql.bz2"
         echo "++ dumping all databases into $l_prefix/var/postgresql/db.dump.sql.bz2"
+        PGPASSWORD="$l_pgpass" \
         $l_prefix/bin/pg_dumpall \
         $l_prefix/bin/pg_dumpall \
-            -U $l_pguser -S$l_pgpass -o -Xuse-set-session-authorization |\
+            -U $l_pguser -o |\
             $l_prefix/lib/openpkg/bzip2 -9 \
             $l_prefix/lib/openpkg/bzip2 -9 \
                 >$l_prefix/var/postgresql/db.dump.sql.bz2
                 >$l_prefix/var/postgresql/db.dump.sql.bz2
         chown ${l_rusr}:${l_rgrp} $l_prefix/var/postgresql/db.dump.sql.bz2
         chown ${l_rusr}:${l_rgrp} $l_prefix/var/postgresql/db.dump.sql.bz2
@@ -185,5 +194,9 @@ case $cmd in
             sleep 4
             sleep 4
         fi
         fi
         ;;
         ;;
+    * )
+        echo "$0:ERROR: unknown command \"$cmd\"" 1>&2
+        exit 1
+        ;;
 esac
 esac
 
 

+ 9 - 1
postgresql/postgresql.spec

@@ -336,7 +336,11 @@ AutoReqProv:  no
                   echo "so we strongly recommend that you backup your existing database"
                   echo "so we strongly recommend that you backup your existing database"
                   echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
                   echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
                   echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
                   echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
-                  echo "Alternatively, if you want force this package to be installed without"
+                  echo "If this fails for some reasons, try to dump your data manually:"
+                  echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
+                  echo "      $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
+                  echo "      >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
+                  echo "Alternatively, if you want to force this package to be installed without"
                   echo "performing a database dump, run the following command before upgrading:"
                   echo "performing a database dump, run the following command before upgrading:"
                   echo "    \$ PG_MIGRATE=ignore; export PG_MIGRATE"
                   echo "    \$ PG_MIGRATE=ignore; export PG_MIGRATE"
                 ) | %{l_rpmtool} msg -b -t error
                 ) | %{l_rpmtool} msg -b -t error
@@ -414,6 +418,10 @@ AutoReqProv:  no
                   echo "so we strongly recommend you to recreate the existing database under"
                   echo "so we strongly recommend you to recreate the existing database under"
                   echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
                   echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
                   echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_dump restore"
                   echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_dump restore"
+                  echo "If this fails for some reasons, try to restore your data manually:"
+                  echo "    \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ "
+                  echo "      $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
+                  echo "      $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1"
                 ) | %{l_rpmtool} msg -b -t warn
                 ) | %{l_rpmtool} msg -b -t warn
             fi
             fi
         fi
         fi