pg_dumpall integration. now you can export your entire cluster if you like
authorchriskl <chriskl>
Wed, 4 Aug 2004 07:44:02 +0000 (07:44 +0000)
committerchriskl <chriskl>
Wed, 4 Aug 2004 07:44:02 +0000 (07:44 +0000)
HISTORY
all_db.php
classes/Misc.php
database.php
dataexport.php
dbexport.php

diff --git a/HISTORY b/HISTORY
index 83d4803067ef53ec8d437c5b2810ba6215104548..6c8606d64f0e5c547e894bab0c7892e7892f024f 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -20,6 +20,8 @@ Features
   jumping between areas.
 * Much improved grant/revoke feature
 * Allow creating and viewing composite types
+* pg_dumpall integration.  Now you can download the entire cluster via
+  phpPgAdmin.
 
 Translations
 * Arabic from Zaki
index ac81212b446b7ddf18a5c57e0d258a6de35180c9..bc8e74021b71cc19493a1281bb7e14afe3350031 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage databases within a server
         *
-        * $Id: all_db.php,v 1.31 2004/07/19 10:21:36 jollytoad Exp $
+        * $Id: all_db.php,v 1.32 2004/08/04 07:44:02 chriskl Exp $
         */
 
        // Include application functions
@@ -21,6 +21,7 @@
                global $PHP_SELF, $lang, $_reload_drop_database;
 
                if ($confirm) {
+                       $misc->printNav('server','databases');
                        $misc->printTitle(array($lang['strdatabases'], $misc->printVal($_REQUEST['db']), $lang['strdrop']), 'drop_database');
                        echo "<p>", sprintf($lang['strconfdropdatabase'], $misc->printVal($_REQUEST['db'])), "</p>\n";  
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                // Fetch all tablespaces from the database
                if ($data->hasTablespaces()) $tablespaces = &$data->getTablespaces();
 
+               $misc->printNav('server','databases');
                $misc->printTitle(array($lang['strdatabases'], $lang['strcreatedatabase']), 'create_database');
                $misc->printMsg($msg);
                
+               
                echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                echo "<table>\n";
                echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strname']}</th>\n";
                }
        }       
 
+       /**
+        * Displays options for cluster download
+        */
+       function doExport($msg = '') {
+               global $data, $misc;
+               global $PHP_SELF, $lang;
+
+               $misc->printNav('server','export');
+               $misc->printTitle(array($lang['strdatabases'], $lang['strexport']));
+               $misc->printMsg($msg);
+
+               echo "<form action=\"dbexport.php\" method=\"post\">\n";
+               echo "<table>\n";
+               echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n";
+               // Data only
+               echo "<tr><th class=\"data left\" rowspan=\"2\">";
+               echo "<input type=\"radio\" name=\"what\" value=\"dataonly\" checked=\"checked\" />{$lang['strdataonly']}</th>\n";
+               echo "<td>{$lang['strformat']}</td>\n";
+               echo "<td><select name=\"d_format\">\n";
+               echo "<option value=\"copy\">COPY</option>\n";
+               echo "<option value=\"sql\">SQL</option>\n";
+               echo "</select>\n</td>\n</tr>\n";
+               echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"d_oids\" /></td>\n</tr>\n";
+               // Structure only
+               echo "<tr><th class=\"data left\"><input type=\"radio\" name=\"what\" value=\"structureonly\" />{$lang['strstructureonly']}</th>\n";
+               echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"s_clean\" /></td>\n</tr>\n";
+               // Structure and data
+               echo "<tr><th class=\"data left\" rowspan=\"3\">";
+               echo "<input type=\"radio\" name=\"what\" value=\"structureanddata\" />{$lang['strstructureanddata']}</th>\n";
+               echo "<td>{$lang['strformat']}</td>\n";
+               echo "<td><select name=\"sd_format\">\n";
+               echo "<option value=\"copy\">COPY</option>\n";
+               echo "<option value=\"sql\">SQL</option>\n";
+               echo "</select>\n</td>\n</tr>\n";
+               echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"sd_clean\" /></td>\n</tr>\n";
+               echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"sd_oids\" /></td>\n</tr>\n";
+               echo "</table>\n";
+               
+               echo "<h3>{$lang['stroptions']}</h3>\n";
+               echo "<p><input type=\"radio\" name=\"output\" value=\"show\" checked=\"checked\" />{$lang['strshow']}\n";
+               echo "<br/><input type=\"radio\" name=\"output\" value=\"download\" />{$lang['strdownload']}</p>\n";
+
+               echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
+               echo "<p><input type=\"hidden\" name=\"mode\" value=\"cluster\" />\n";          
+               echo $misc->form;
+               echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
+               echo "</form>\n";
+       }
+
        /**
         * Show default list of databases in the server
         */
                global $data, $conf, $misc;
                global $PHP_SELF, $lang;
 
+               $misc->printNav('server','databases');
                $misc->printTitle(array($lang['strdatabases']), 'managing_databases');
                $misc->printMsg($msg);
                
        }
 
        $misc->printHeader($lang['strdatabases']);
-       $misc->printBody();
-       $misc->printNav('server','databases');
+       $misc->printBody();     
 
        switch ($action) {
+               case 'export':
+                       doExport();
+                       break;
                case 'save_create':
                        if (isset($_POST['cancel'])) doDefault();
                        else doSaveCreate();
index fc2f901854969f128a297b5344db4244b41b80de..553b763cfbeec10807959ac148c4d19748a4f929 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.83 2004/07/22 12:47:38 jollytoad Exp $
+        * $Id: Misc.php,v 1.84 2004/08/04 07:44:03 chriskl Exp $
         */
         
        class Misc {
                                                        'url'   => "tablespaces.php",
                                                        'hide'  => (!$data->hasTablespaces()),
                                                ),
+                                               'export' => array (
+                                                       'title' => $lang['strexport'],
+                                                       'url'   => "all_db.php?action=export",
+                                                       'hide'  => (!$this->isDumpEnabled()),
+                                               ),
                                        );
 
                                case 'database':
                                                ),
                                                'privileges' => array (
                                                        'title' => $lang['strprivileges'],
-                                                       'url'   => "privileges.php?{$vars}&type=database&object=" . urlencode($_REQUEST['database']),
+                                                       // Handle either 'object' or 'database' being set
+                                                       'url'   => "privileges.php?{$vars}&type=database&object=" . urlencode((isset($_REQUEST['database']) ? $_REQUEST['database'] : $_REQUEST['object'])),
                                                        'hide'  => (!isset($data->privlist['database'])),
                                                ),
                                                'languages' => array (
index 23f29ee93b48d9ce8e8b1b382d1f395a1b51e542..d03e91850a24567b4b10e089506cafccbf8fc7d5 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.57 2004/08/04 02:07:02 chriskl Exp $
+        * $Id: database.php,v 1.58 2004/08/04 07:44:03 chriskl Exp $
         */
 
        // Include application functions
                echo "<br /><input type=\"radio\" name=\"output\" value=\"gzipped\" />{$lang['strdownloadgzipped']}</p>\n";
 
                echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
+               echo "<p><input type=\"hidden\" name=\"mode\" value=\"database\" />\n";         
                echo $misc->form;
                echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
                echo "</form>\n";
index 7cb22f369e602d82b361883c25da7c3a8f1b6815..c2272a0fc338ebd748924c17d0852c1b4b538298 100644 (file)
@@ -4,7 +4,7 @@
         * Does an export to the screen or as a download.  This checks to
         * see if they have pg_dump set up, and will use it if possible.
         *
-        * $Id: dataexport.php,v 1.15 2004/06/07 15:39:38 chriskl Exp $
+        * $Id: dataexport.php,v 1.16 2004/08/04 07:44:03 chriskl Exp $
         */
 
        $extensions = array(
@@ -32,7 +32,7 @@
                                // instead of custom dump code
                                if ($misc->isDumpEnabled()
                                                && ($_REQUEST['d_format'] == 'copy' || $_REQUEST['d_format'] == 'sql')) {
-                                       $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
+                                       $url = 'dbexport.php?mode=database&database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
                                        if ($data->hasSchemas()) $url .= '&schema=' . urlencode($_REQUEST['schema']);
@@ -53,7 +53,7 @@
                                // Check to see if they have pg_dump set up and if they do, use that
                                // instead of custom dump code
                                if ($misc->isDumpEnabled()) {
-                                       $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
+                                       $url = 'dbexport.php?mode=database&database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
                                        if ($data->hasSchemas()) $url .= '&schema=' . urlencode($_REQUEST['schema']);
@@ -70,7 +70,7 @@
                                // Check to see if they have pg_dump set up and if they do, use that
                                // instead of custom dump code
                                if ($misc->isDumpEnabled()) {
-                                       $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
+                                       $url = 'dbexport.php?mode=database&database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
                                        if ($data->hasSchemas()) $url .= '&schema=' . urlencode($_REQUEST['schema']);
index a3a0908f11a5d3db2d3fffa9b957efabb4f4eb47..1e3d3ed5282bf1c554a9d3a4c740dac8c8b6b510 100644 (file)
@@ -3,7 +3,7 @@
         * Does an export of a database or a table (via pg_dump)
         * to the screen or as a download.
         *
-        * $Id: dbexport.php,v 1.11 2004/06/06 06:34:28 chriskl Exp $
+        * $Id: dbexport.php,v 1.12 2004/08/04 07:44:03 chriskl Exp $
         */
 
        // Include application functions
                // Prepare command line arguments
                $hostname = $conf['servers'][$_SESSION['webdbServerID']]['host'];
                $port = $conf['servers'][$_SESSION['webdbServerID']]['port'];
-               $database = escapeshellarg($_REQUEST['database']);              
-
-               // Build command for executing pg_dump
-               $cmd = escapeshellcmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path']) . " -i";
+               
+               // Check if we're doing a cluster-wide dump or just a per-database dump
+               if ($_REQUEST['mode'] == 'database') {
+                       // Build command for executing pg_dump.  '-i' means ignore version differences.
+                       $cmd = escapeshellcmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path']) . " -i";
+               }
+               else {
+                       // Build command for executing pg_dump.  '-i' means ignore version differences.
+                       $cmd = escapeshellcmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dumpall_path']) . " -i";
+               }
+               
                if ($hostname !== null && $hostname != '') {
                        $cmd .= " -h " . escapeshellarg($hostname);
                }
@@ -47,7 +54,7 @@
                }
                
                // Check for a table specified
-               if (isset($_REQUEST['table'])) {                        
+               if (isset($_REQUEST['table']) && $_REQUEST['mode'] == 'database') {                     
                        // If we are 7.4 or higher, assume they are using 7.4 pg_dump and
                        // set dump schema as well.  Also, mixed case dumping has been fixed
                        // then..
@@ -63,7 +70,7 @@
                }
 
                // Check for GZIP compression specified
-               if ($_REQUEST['output'] == 'gzipped') {
+               if ($_REQUEST['output'] == 'gzipped' && $_REQUEST['mode'] == 'database') {
                        $cmd .= " -Z 9";
                }
                                
@@ -84,7 +91,9 @@
                                break;
                }
                
-               $cmd .= " {$database}";
+               if ($_REQUEST['mode'] == 'database') {
+                       $cmd .= " " . escapeshellarg($_REQUEST['database']);
+               }
 
                // Execute command and return the output to the screen
                passthru($cmd);