App::MBUtiny::Storage - App::MBUtiny storage class
Version 1.00
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;
App::MBUtiny storage class
Storage - is a directory on disk, a remote FTP/SFTP/ HTTP server or CLI process that simulates storage functional.
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
$storage->cleanup();
Flushes errors and the status property to defaults
my $status = $storage->del("foo-2019-06-25.tar.gz");
Performs the "del" method in all storage subclasses
Returns summary status. See "summary"
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
Callback the "fixup" method. This method called automatically when the put method performs
$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
Performs the "init" method in all storage subclasses and returns self object instance
For internal use only
my @filelist = $storage->list;
Returns summary list of backup files from all available storages
$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
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->storage_status(HTTP => 0); my $storage_status = $storage->storage_status("HTTP");
Sets/gets storage status. For internal use only
my $status = $storage->summary;
Returns summary status.
my $test = $storage->test or die $storage->error;
Performs testing each storage and returns summary status. See "summary"
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], # ... ]
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
See Changes file
Changes
See TODO file
TODO
* none noted
App::MBUtiny
Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
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/
LICENSE
To install App::MBUtiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::MBUtiny
CPAN shell
perl -MCPAN -e shell install App::MBUtiny
For more information on module installation, please visit the detailed CPAN module installation guide.