From 6a1be2373279e92b5ec566e1b77969d5733971da Mon Sep 17 00:00:00 2001 From: hjp Date: Wed, 13 Nov 2013 00:20:00 +0000 Subject: [PATCH] Added dist_abstract and removed dependency on SHA1. Added script simba_export. --- Build.PL | 3 ++- scripts/simba_export | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 scripts/simba_export diff --git a/Build.PL b/Build.PL index ad26de6..2ec88c4 100644 --- a/Build.PL +++ b/Build.PL @@ -6,15 +6,16 @@ use Simba::Build; my $build = Simba::Build->new ( module_name => 'Simba', + dist_abstract => 'Simple Integrated Multiplatform Backup and Archive', license => 'perl', requires => { 'Readonly' => 0, - 'Digest::SHA1' => 0, 'Config::YAML' => 0, }, script_files => [ 'scripts/da', 'scripts/backup', + 'scripts/simba_export', ], ); $build->create_build_script; diff --git a/scripts/simba_export b/scripts/simba_export new file mode 100644 index 0000000..3b854cc --- /dev/null +++ b/scripts/simba_export @@ -0,0 +1,47 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Simba::CA; +use autodie; + +my $basedir = $ARGV[0]; +usage() unless $basedir; + +my $ca = Simba::CA->new({ + dbi_file => $ENV{SIMBA_DB_CONN} || "$ENV{HOME}/.dbi/simba", + log_fh => \*STDERR, + }); +my $dbh = $ca->{dbh}; + +my $sessions = $dbh->selectcol_arrayref("select id from sessions order by id"); +for my $session_id (@$sessions) { + next if (-f "$basedir/$session_id.tsv"); + $ca->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, '>', "$basedir/$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); +} + +sub usage { + print STDERR "Usage: $0 basedir\n"; + exit(1); +}