Skip to content

Commit

Permalink
Fixed the TO UI.Tools.DBDump facility
Browse files Browse the repository at this point in the history
  • Loading branch information
dewrich committed Nov 14, 2016
1 parent e30afe9 commit 4c30936
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 0 additions & 5 deletions traffic_ops/app/lib/UI/ConfigFiles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,13 @@ sub server_data {

my $server;

# if ( defined( $self->app->session->{server_data} ) ) {
# $server = $self->app->session->{server_data};
# return $server;
# }
if ( $id =~ /^\d+$/ ) {
$server = $self->db->resultset('Server')->search( { id => $id } )->single;
}
else {
$server = $self->db->resultset('Server')->search( { host_name => $id } )->single;
}

# $self->app->session->{server_data} = $server;
return $server;
}

Expand Down
13 changes: 7 additions & 6 deletions traffic_ops/app/lib/UI/GenDbDump.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ package UI::GenDbDump;
#
#
use Mojo::Base 'Mojolicious::Controller';
use Data::Dumper;

sub dbdump {
my $self = shift;
my $filename = $self->param('filename');

my $db_user = $Schema::user;
my $db_pass = $Schema::pass;
my $db_name = ( split( /:/, $Schema::dsn ) )[2];
my $db_host = $Schema::hostname;
$db_name =~ s/database=//;
my $db_name = $Schema::dsn;
my $host;
my $port;
my $dsn = $Schema::dsn;
($db_name, $host, $port) = $dsn =~ /:database=(\w+);host=(\w+);port=(\d+)/;

my $cmd = "pg_dump --username=" . $db_user . " " . $db_name . " > " . $filename;
my $cmd = "pg_dump -U " . $db_user . " -h localhost -C --column-insert";
my $extension = ".psql";

my $data = `$cmd`;


$self->res->headers->content_type("application/download");

$self->res->headers->content_disposition( "attachment; filename=\"" . $filename . "\"" );
$self->render( data => $data );
}
Expand Down

0 comments on commit 4c30936

Please sign in to comment.