use File::Spec::Functions;
use File::stat;
use File::Copy;
+use File::Glob ':glob';
use Locale::gettext;
use POSIX qw(setlocale LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME);
sub perform_nodes {
my $node_list = shift;
+ my $K = "perform_nodes(): ";
my $dir_list = [];
my $file_list = [];
sub perform_dirs {
my $dir_list = shift;
+ my $K = "perform_dirs(): ";
my ( $sublist, $newlist, $basename );
for my $d ( @$dir_list ) {
- _debug( 1, sprintf( $l->get("Backup of directory '%s' ..."), $d ) );
- @$sublist = ( glob( catfile( $d, ".*" ) ), glob( catfile( $d, "*" ) ) );
+ _debug( 1, sprintf( $K . $l->get("Backup of directory '%s' ..."), $d ) );
+ $d =~ s/\/$// unless $d eq "/";
+ my $pattern = catfile( '"' . $d . '"', "{,.}*" );
+ $pattern = catfile( $d, "{,.}*" );
+ _debug( 2, $K . "Suchpattern: '" . $pattern . "'." );
+ #@$sublist = ( glob( $pattern1 ), glob( $pattern2 ) );
+ @$sublist = bsd_glob( $pattern, GLOB_TILDE | GLOB_BRACE | GLOB_NOSORT );
+ _debug( 2, $K . "Verzeichnisinhalt: " . Dumper($sublist) );
$newlist = [];
for ( @$sublist ) {
$basename = basename($_);
sub perform_files {
my $file_list = shift;
+ my $K = "perform_files(): ";
for my $f ( @$file_list ) {
- _debug( 1, sprintf( $l->get("Backup of file '%s' ..."), $f ) );
+ _debug( 1, $K . sprintf( $l->get("Backup of file '%s' ..."), $f ) );
return 0 unless backup_file($f);
}
sub backup_file {
my $file = shift;
+ my $K = "backup_file(): ";
my $fstat = stat($file) or return 0;
my $mtime = [localtime($fstat->mtime)];
my $pdir = dirname($file);
my $odir = catdir( $pdir, $olddir );
- _debug( 1, sprintf( $l->get("Using Old-Dir '%s'."), $odir ) );
+ _debug( 1, sprintf( $K . $l->get("Using Old-Dir '%s'."), $odir ) );
return undef unless create_dir($odir);
my $bakfile = catfile( $odir, basename($file) . $datepat );
print " - " . $file . " -> " . $bakfile . "\n";
return 0;
}
- _debug( 2, sprintf( $l->get("Changing timestamp of '%s' ..."), $bakfile ) );
+ _debug( 2, sprintf( $K . $l->get("Changing timestamp of '%s' ..."), $bakfile ) );
unless ( utime $fstat->atime, $fstat->mtime, $bakfile ) {
_error( undef, sprintf( $l->get("Could not change timestamps of '%s': "), $bakfile ) . $! );
}
# wenn root, dann Besitzerschaft der gesicherten Datei uebernehmen
unless ( $> ) {
- _debug( 2, sprintf( $l->get("Changing ownership of '%s' to '%s:%s' ...\n"), $bakfile, $fstat->uid, $fstat->gid ) );
+ _debug( 2, sprintf( $K . $l->get("Changing ownership of '%s' to '%s:%s' ...\n"), $bakfile, $fstat->uid, $fstat->gid ) );
unless ( chown $fstat->uid, $fstat->gid, $bakfile ) {
_error( undef, sprintf( $l->get("Could not change owner of '%s' to '%s:%s': "), $bakfile, $fstat->uid, $fstat->gid ) . $! );
}