At the end of a run, export all sessions which haven't been exported yet
to the current basedir.
This commit is contained in:
parent
5ae126f797
commit
6392f06826
|
@ -150,6 +150,7 @@ sub run {
|
||||||
for (sort keys %{ $self->{times} }) {
|
for (sort keys %{ $self->{times} }) {
|
||||||
$self->log(3, " $_: $self->{times}{$_} s");
|
$self->log(3, " $_: $self->{times}{$_} s");
|
||||||
}
|
}
|
||||||
|
$self->export();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub backup2disk {
|
sub backup2disk {
|
||||||
|
@ -822,6 +823,44 @@ sub adjust_partitions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub export {
|
||||||
|
my ($self) = @_;
|
||||||
|
my $dbh = $self->{dbh};
|
||||||
|
my $exportdir = $self->basedir . "/export";
|
||||||
|
|
||||||
|
my $sessions = $dbh->selectcol_arrayref("select id from sessions order by id");
|
||||||
|
for my $session_id (@$sessions) {
|
||||||
|
next if (-f "$exportdir/$session_id.tsv"
|
||||||
|
|| -f "$exportdir/$session_id.tsv.gz");
|
||||||
|
$self->log(3, "exporting session $session_id");
|
||||||
|
my $sth
|
||||||
|
= $dbh->prepare(
|
||||||
|
qq{select sessions.id as "sessions.id", start_date, end_date, prefix,
|
||||||
|
instances.id as "instances.id", file_id, date, online,
|
||||||
|
versions2.id as "versions2.id", file_type, file_size, file_mtime, file_owner, file_group, file_acl, file_unix_bits, file_rdev, checksum, file_linktarget,
|
||||||
|
files.id as "files.id", path,
|
||||||
|
filesets.id as "filesets.id", host, dir, options, pid
|
||||||
|
from sessions, instances, versions2, files, filesets
|
||||||
|
where sessions.id=$session_id
|
||||||
|
and sessions.id=instances.session
|
||||||
|
and instances.version=versions2.id
|
||||||
|
and instances.file=files.id
|
||||||
|
and files.fileset=filesets.id
|
||||||
|
});
|
||||||
|
$sth->execute;
|
||||||
|
open my $fh, '>', "$exportdir/$session_id.tsv.$$";
|
||||||
|
print $fh join("\t", @{$sth->{NAME}}), "\n";
|
||||||
|
while (my $r = $sth->fetchrow_arrayref) {
|
||||||
|
no warnings 'uninitialized';
|
||||||
|
print $fh join("\t", @$r), "\n";
|
||||||
|
}
|
||||||
|
close($fh);
|
||||||
|
rename "$exportdir/$session_id.tsv.$$", "$exportdir/$session_id.tsv";
|
||||||
|
system "gzip", "$exportdir/$session_id.tsv";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
sub DESTROY {
|
sub DESTROY {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$self->{dbh}->disconnect();
|
$self->{dbh}->disconnect();
|
||||||
|
|
Loading…
Reference in New Issue