Added an option to the restore form to limit the restore to only certain tables
authorJamie Cameron <jcameron@webmin.com>
Thu, 2 Dec 2010 06:05:57 +0000 (22:05 -0800)
committerJamie Cameron <jcameron@webmin.com>
Thu, 2 Dec 2010 06:05:57 +0000 (22:05 -0800)
postgresql/CHANGELOG
postgresql/backup_form.cgi
postgresql/lang/en
postgresql/restore.cgi
postgresql/restore_form.cgi

index ce13a75..a0eb600 100644 (file)
@@ -71,3 +71,5 @@ Re-wrote the entire user interface to use Webmin's new UI library, for a more co
 Added a history of previous commands to the Execute SQL page.
 ---- Changes since 1.510 ----
 Added greater than / less than selectors to the table data search form.
+---- Changes since 1.530 ----
+Added an option to the restore form to limit the restore to only certain tables.
index 9a5ff29..cdb06bd 100755 (executable)
@@ -67,12 +67,17 @@ if (!$in{'all'}) {
        # Show input to select tables
        $t = $c{'backup_tables_'.$in{'db'}};
        @tables = &list_tables($in{'db'});
-       print &ui_table_row($text{'backup_tables'},
-               &ui_radio("tables_def", $t ? 0 : 1,
-                         [ [ 1, $text{'backup_alltables'} ],
-                           [ 0, $text{'backup_seltables'} ] ])."<br>".
-               &ui_select("tables", [ split(/\s+/, $t) ],
-                          [ sort @tables ], 5, 1));
+       if (@tables) {
+               print &ui_table_row($text{'backup_tables'},
+                       &ui_radio("tables_def", $t ? 0 : 1,
+                                 [ [ 1, $text{'backup_alltables'} ],
+                                   [ 0, $text{'backup_seltables'} ] ])."<br>".
+                       &ui_select("tables", [ split(/\s+/, $t) ],
+                                  [ sort @tables ], 5, 1));
+               }
+       else {
+               print &ui_hidden("tables_def", 1);
+               }
        }
 
 print &ui_hidden_table_end("main");
index faf5f2e..f535896 100644 (file)
@@ -453,6 +453,9 @@ restore_ecmd=The restore command $1 was not found on your system
 restore_ecannot=You are not allowed to restore backups
 restore_only=Only restore data, not tables?
 restore_clean=Delete tables before restoring?
+restore_tables=Tables to restore
+restore_tables1=All in backup file
+restore_tables0=Listed tables
 restore_failed=Restore failed : $1
 
 backup_title=Backup Database
index 025c09e..63ed02d 100755 (executable)
@@ -23,19 +23,20 @@ else {
        &close_tempfile(DATA);
        }
 
-$db_find_f = 0 ;
-
-if ( $in{'db'} ) {
-
-    foreach ( &list_databases() ) {
-
-        if ( $_ eq $in{'db'} ) { $db_find_f = 1 ; }
-    }
-}
+# Validate tables list
+if ($in{'tables_def'}) {
+       $tables = undef;
+       }
+else {
+       $in{'tables'} =~ /\S/ || &error($text{'restore_etables'});
+       $tables = [ split(/\s+/, $in{'tables'}) ];
+       }
 
-if ( $db_find_f == 0 ) { &error ( &text ( 'restore_edb' ) ) ; }
+# Validate database
+&indexof($in{'db'}, &list_databases()) >= 0 ||
+       &error(&text('restore_edb'));
 
-$err = &restore_database($in{'db'}, $path, $in{'only'}, $in{'clean'});
+$err = &restore_database($in{'db'}, $path, $in{'only'}, $in{'clean'}, $tables);
 if ($err) {
        &error(&text('restore_failed', "<pre>$err</pre>"));
        }
index 7ea5765..b03e5a0 100755 (executable)
@@ -34,6 +34,11 @@ print &ui_table_row($text{'restore_only'},
 print &ui_table_row($text{'restore_clean'},
                    &ui_yesno_radio("clean", 0));
 
+print &ui_table_row($text{'restore_tables'},
+                   &ui_opt_textbox("tables", undef, 60,
+                                   $text{'restore_tables1'}."<br>",
+                                   $text{'restore_tables0'}));
+
 print &ui_table_end();
 print &ui_form_end([ [ "go", $text{'restore_go'} ] ]);