The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::MBUtiny::Storage - App::MBUtiny storage class

VIRSION

Version 1.00

SYNOPSIS

    use App::MBUtiny::Storage;

    my $storage = new App::MBUtiny::Storage(
        name => $name, # Backup name
        host => $host, # Host config section
        path => "/tmp/mbutiny/files", # Where is located backup archive
    );

    print $storage->error unless $storage->status;

DESCRIPTION

App::MBUtiny storage class

Storage - is a directory on disk, a remote FTP/SFTP/ HTTP server or CLI process that simulates storage functional.

new

    my $storage = new App::MBUtiny::Storage(
        name => $name, # Backup name
        host => $host, # Host config section
        path => "/tmp/mbutiny/files", # Where is located backup archive
        fixup => sub {
            my $strg = shift; # Storage object
            my $oper = shift // 'noop'; # Operation name
            my @args = @_;

            return 1;
        },
        validate => sub {
            my $strg = shift; # storage object
            my $file = shift; # fetched file name

            return 1;
        },
    );

Returns storage object

cleanup

    $storage->cleanup();

Flushes errors and the status property to defaults

del

    my $status = $storage->del("foo-2019-06-25.tar.gz");

Performs the "del" method in all storage subclasses

Returns summary status. See "summary"

error

    print $storage->error("Foo"); # Foo
    print $storage->error("Bar"); # Foo\nBar
    print $storage->error; # Foo\nBar
    print $storage->error(""); # <"">

Sets and gets the error pool

fixup

Callback the "fixup" method. This method called automatically when the put method performs

get

    $st = $storage->get(
        name => "foo-2019-06-25.tar.gz",
        file => "/full/path/to/foo-2019-06-25.tar.gz",
    );

Fetching backup file to specified file path from each storage until first successful result

Returns summary status. See "summary"

init

Performs the "init" method in all storage subclasses and returns self object instance

For internal use only

list

    my @filelist = $storage->list;

Returns summary list of backup files from all available storages

put

    $st = $storage->put(
        name => "foo-2019-06-25.tar.gz",
        file => "/full/path/to/foo-2019-06-25.tar.gz",
        size => 123456,
    );

Sending backup file to each available storage

Returns summary status. See "summary"

status

    my $new_status = $storage->status(0);

Sets new status value and returns it

    my $status = $storage->status;

Returns status value. 0 - Error; 1 - Ok

storage_status

    $storage->storage_status(HTTP => 0);
    my $storage_status = $storage->storage_status("HTTP");

Sets/gets storage status. For internal use only

summary

    my $status = $storage->summary;

Returns summary status.

1 PASS status. Process successful
0 FAIL status. Process failed
-1 SKIP status. Process was skipped

test

    my $test = $storage->test or die $storage->error;

Performs testing each storage and returns summary status. See "summary"

test_report

    foreach my $tr ($storage->test_report) {
        my ($st, $vl, $er) = @$tr;
            print STDOUT $vl, "\n";
            print STDOUT $st ? $st < 0 ? 'SKIP' : 'PASS' : 'FAIL', "\n";
            print STDERR $er, "\n";
        );
    }

Returns list of test result for each storage as:

    [
        [STATUS, NAME, ERROR],
        # ...
    ]

validate

Callback the "validate" method. This method called automatically when the get method performs

This method can returns 0 or 1. 0 - validation failed; 1 - validation successful

HISTORY

See Changes file

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

App::MBUtiny

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/