File: backup_restore.pl

package info (click to toggle)
libdbd-odbc-perl 1.61-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,424 kB
  • sloc: perl: 8,928; ansic: 6,456; makefile: 33; sql: 8
file content (27 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# $Id$
# backup and restore a MS SQL Server database
# needs to loop over odbc_more_results or the procedure does not finish
use DBI;
use strict;
use warnings;
use Data::Dumper;

sub _error_handler {
    print Dumper(\@_);
    0;
}

my $h = DBI->connect;
$h->{RaiseError} = 1;
$h->{HandleError} = \&_error_handler;

eval {$h->do('create database foo');};

$h->do(q{backup database foo to disk='c:\foo.bak'});

my $s = $h->prepare(q{restore database foo from disk='c:\foo.bak'});
$s->execute;

while ($s->{odbc_more_results}) {
    print "More\n";
}