summaryrefslogtreecommitdiff
path: root/httemplate/misc/dump.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc/dump.cgi')
-rw-r--r--httemplate/misc/dump.cgi19
1 files changed, 19 insertions, 0 deletions
diff --git a/httemplate/misc/dump.cgi b/httemplate/misc/dump.cgi
new file mode 100644
index 0000000..dc1323b
--- /dev/null
+++ b/httemplate/misc/dump.cgi
@@ -0,0 +1,19 @@
+<%
+ if ( driver_name =~ /^Pg$/ ) {
+ my $dbname = (split(':', datasrc))[2];
+ if ( $dbname =~ /[;=]/ ) {
+ my %elements = map { /^(\w+)=(.*)$/; $1=>$2 } split(';', $dbname);
+ $dbname = $elements{'dbname'};
+ }
+ open(DUMP,"pg_dump $dbname |");
+ } else {
+ eidiot "don't (yet) know how to dump ". driver_name. " databases\n";
+ }
+
+ http_header('Content-Type' => 'text/plain' );
+
+ while (<DUMP>) {
+ print $_;
+ }
+ close DUMP;
+%>