X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=prj-upload-db.pl;h=695e36a96d4938c17b06e6df0de672f8aafa9351;hb=e6f25583c4a2f390f4817395cd35dac916a7bec5;hp=d49479ccdadcc097b3e65e130b88f6503ad0490c;hpb=fde4aed663e958e4ed5f932c7cf41435250d6ff0;p=prj-utils.git diff --git a/prj-upload-db.pl b/prj-upload-db.pl index d49479c..695e36a 100755 --- a/prj-upload-db.pl +++ b/prj-upload-db.pl @@ -17,20 +17,26 @@ print "Dumping Local DB...\n"; `mysqldump -C -u$config{local_db_user} -p$config{local_db_pass} $config{local_db_name} > $config{remote_db_name}.sql`; print "Compressing DB...\n"; -`tar -xzvf $config{remote_db_name}.tar.gz`; +`tar -czvf $config{remote_db_name}.tar.gz $config{remote_db_name}.sql`; # upload db print "Uploading DB...\n"; my $scp = Net::SCP->new($config{remote_host}, $config{remote_user}); -$scp->put("$config{remote_db_name}.tar.gz"); +$scp->put("$config{remote_db_name}.tar.gz") or die $scp->{errstr}; print "Logging to $config{remote_host}...\n"; -my $ssh = Net::SSH::Perl->new($config{remote_host}, debug=>0); +my %params; +$params{port} = $config{remote_port}; +$params{debug} = 0; +$params{use_pty} = 1; +my $ssh = Net::SSH::Perl->new($config{remote_host}, %params); $ssh->login($config{remote_user}, $config{remote_pass}); print "Unpacking DB...\n"; my ($stdout, $stderr, $exit) = $ssh->cmd("tar -xzvf $config{remote_db_name}.tar.gz"); print $stdout; +print $stderr; + print "Loading DB...\n"; ($stdout, $stderr, $exit) = $ssh->cmd("mysql -u$config{remote_db_user} -p$config{remote_db_pass} $config{remote_db_name} < $config{remote_db_name}.sql");