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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package GenTest::Reporter::BackupAndRestore;
require Exporter;
@ISA = qw(GenTest::Reporter);
use strict;
use GenTest;
use GenTest::Reporter;
use GenTest::Constants;
my $count = 0;
my $file = '/tmp/rqg_backup';
sub monitor {
my $reporter = shift;
return STATUS_OK if $count > 0;
my $dsn = $reporter->dsn();
my $dbh = DBI->connect($dsn);
unlink('/tmp/rqg_backup');
say("Executing BACKUP DATABASE.");
$dbh->do("BACKUP DATABASE test TO '/tmp/rqg_backup'");
$count++;
if (defined $dbh->err()) {
return STATUS_DATABASE_CORRUPTION;
} else {
return STATUS_OK;
}
}
sub report {
my $reporter = shift;
my $dsn = $reporter->dsn();
my $dbh = DBI->connect($dsn);
say("Executing RESTORE FROM.");
$dbh->do("RESTORE FROM '/tmp/rqg_backup' OVERWRITE");
if (defined $dbh->err()) {
return STATUS_DATABASE_CORRUPTION;
} else {
return STATUS_OK;
}
}
sub type {
return REPORTER_TYPE_PERIODIC | REPORTER_TYPE_SUCCESS;
}
1;
|