App-SimpleBackuper

 view release on metacpan or  search on metacpan

lib/App/SimpleBackuper/DB/BaseTable.pm  view on Meta::CPAN

use warnings FATAL => qw( all );
use Carp;
use Data::Dumper;

sub new {
	my($class, $number_of_records) = @_;
	
	$number_of_records //= 0;
	my @arr = (undef) x $number_of_records;
	
	return bless \@arr => $class;
}

sub find_row {
	my $self = shift;
	my($from, $to) = $self->_find(@_);
	die "Found more then one" if $to > $from;
	return undef if $from > $to;
	return $self->unpack( $self->[ $from ] );
}

lib/App/SimpleBackuper/StorageLocal.pm  view on Meta::CPAN


use strict;
use warnings;

sub new {
	my($class, $path) = @_;
	
	die "Storage path '$path' doesn't exists" if ! -e $path;
	die "Storage path '$path' is not a directory" if ! -d $path;
	
	return bless { path => $path } => $class;
}

sub put {
	my($self, $name, $content_ref) = @_;
	
	open(my $fh, ">", "$self->{path}/$name") or die "Can't write to $self->{path}/$name: $!";
	print $fh $$content_ref;
	close($fh);
	
	return $self;

lib/App/SimpleBackuper/StorageSFTP.pm  view on Meta::CPAN

use strict;
use warnings;
use Try::Tiny;
use Net::SFTP::Foreign;
use Net::SFTP::Foreign::Constants qw(SSH2_FX_CONNECTION_LOST);

sub new {
	my($class, $options) = @_;
	my(undef, $user, $host, $path) = $options =~ /^(([^@]+)@)?([^:]+):(.*)$/;
	
	my $self = bless {user => $user, host => $host, path => $path} => $class;
	$self->_connect();
	
	return $self;
}

sub _connect {
	my($self) = @_;
	
	$self->{sftp} = Net::SFTP::Foreign->new(host => $self->{host}, ($self->{user} ? (user => $self->{user}) : ()), timeout => 30);
	$self->{sftp}->die_on_error("SFTP connect error");

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.457 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )