Subject: | Executing a BACKUP command silently fails with DBD::ODBC |
When executing a BACKUP statement via $dbh->do, the command seems to
complete, but nothing actually happens on the server. The same command
works with DBD::Sybase. Attached the test script (easy to follow, but
not easy to run as it implies checking server-side files), the output of
said script, and the output with DBI_TRACE=5.
Cheers!
Subject: | backup_test_output.txt |
ok 1 - No backup file
# 9.00.3042.00 via dbi:ODBC:server=192.168.0.12;port=1433;driver=FreeTDS;tds_version=8.0
ok 2 - no throw
not ok 3 - Backup Test_odbc.bak created
# Failed test 'Backup Test_odbc.bak created'
# at backup_test.pl line 49.
ok 4 - No backup file
# 9.00.3042.00 via dbi:Sybase:server=192.168.0.12:1433
ok 5 - no throw
ok 6 - Backup Test_sybase.bak created
1..6
# Looks like you failed 1 test of 6.
Subject: | backup_test_output_with_trace.txt |
Message body is not shown because it is too large.
Subject: | backup_test.pl |
use warnings;
use strict;
use Test::More;
use Test::Exception;
use DBI;
my $dsns = {
odbc => 'dbi:ODBC:server=192.168.0.12;port=1433;driver=FreeTDS;tds_version=8.0',
sybase => 'dbi:Sybase:server=192.168.0.12:1433',
};
for my $type (keys %$dsns) {
my $fn = "Test_${type}.bak";
unlink "/mnt/$fn" if (-f "/mnt/$fn");
ok (! -f "/mnt/$fn", "No backup file");
lives_ok {
my $dbh = DBI->connect(
$dsns->{$type},
'sa',
'123456'
);
note $dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion')->{Character_Value} . " via $dsns->{$type}";
$dbh->do (<<EOS);
BACKUP DATABASE [BackTest]
TO DISK = N'D:\\SQL_BACKUPS\\$fn'
WITH DESCRIPTION = N'Test $type Backup',
NAME = N'TST $type BKP',
SKIP,
NOREWIND,
NOUNLOAD,
STATS = 10,
CHECKSUM,
NOFORMAT,
NOINIT
EOS
} 'no throw';
sleep 2; # async file creation
ok (-f "/mnt/$fn", "Backup $fn created");
}
done_testing;