add autodetect FileLog directorys
This commit is contained in:
parent
ea2f9ea909
commit
894ed8817e
38
98_backup.pm
38
98_backup.pm
@ -56,6 +56,7 @@ use GPUtils qw(GP_Import)
|
|||||||
BEGIN {
|
BEGIN {
|
||||||
GP_Import(
|
GP_Import(
|
||||||
qw(AttrVal
|
qw(AttrVal
|
||||||
|
InternalVal
|
||||||
gettimeofday
|
gettimeofday
|
||||||
ResolveDateWildcards
|
ResolveDateWildcards
|
||||||
attr
|
attr
|
||||||
@ -66,7 +67,8 @@ BEGIN {
|
|||||||
TimeNow
|
TimeNow
|
||||||
BC_searchTelnet
|
BC_searchTelnet
|
||||||
BC_telnetDevice
|
BC_telnetDevice
|
||||||
DoTrigger)
|
DoTrigger
|
||||||
|
devspec2array)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +78,9 @@ sub CommandBackup($$) {
|
|||||||
my ( $cl, $param ) = @_;
|
my ( $cl, $param ) = @_;
|
||||||
|
|
||||||
my $byUpdate = ( $param && $param eq 'startedByUpdate' );
|
my $byUpdate = ( $param && $param eq 'startedByUpdate' );
|
||||||
my $modpath = AttrVal( 'global', 'modpath', '' );
|
my $modpath = AttrVal( 'global', 'modpath', '' );
|
||||||
my $configfile = AttrVal( 'global', 'configfile', '' );
|
my $configfile = AttrVal( 'global', 'configfile', '' );
|
||||||
my $statefile = AttrVal( 'global', 'statefile', '' );
|
my $statefile = AttrVal( 'global', 'statefile', '' );
|
||||||
my $logDir = AttrVal( 'global', 'logdir', 'none' );
|
|
||||||
my $now = gettimeofday();
|
my $now = gettimeofday();
|
||||||
my @t = localtime($now);
|
my @t = localtime($now);
|
||||||
$statefile = ResolveDateWildcards( $statefile, @t );
|
$statefile = ResolveDateWildcards( $statefile, @t );
|
||||||
@ -138,8 +139,8 @@ sub CommandBackup($$) {
|
|||||||
|
|
||||||
$ret = readModpath( $modpath, $backupdir );
|
$ret = readModpath( $modpath, $backupdir );
|
||||||
|
|
||||||
## add extra logdir path to backup
|
## add all logfile path to pathname array
|
||||||
push( @pathname, $logDir ) if ( $logDir ne 'none' );
|
$ret = addLogPathToPathnameArray($modpath);
|
||||||
|
|
||||||
# create archiv
|
# create archiv
|
||||||
$ret = createArchiv( $backupdir, $cl, $byUpdate );
|
$ret = createArchiv( $backupdir, $cl, $byUpdate );
|
||||||
@ -236,10 +237,10 @@ sub createArchiv($$$) {
|
|||||||
my $cmd = '';
|
my $cmd = '';
|
||||||
if ( !defined($backupcmd) ) {
|
if ( !defined($backupcmd) ) {
|
||||||
if ( lc($symlink) eq 'no' ) {
|
if ( lc($symlink) eq 'no' ) {
|
||||||
$tarOpts = 'cfz';
|
$tarOpts = 'czf';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tarOpts = 'chfz';
|
$tarOpts = 'chzf';
|
||||||
}
|
}
|
||||||
|
|
||||||
# prevents tar's output of "Removing leading /" and return total bytes of
|
# prevents tar's output of "Removing leading /" and return total bytes of
|
||||||
@ -282,6 +283,29 @@ sub createArchiv($$$) {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub addLogPathToPathnameArray($) {
|
||||||
|
my $modpath = shift;
|
||||||
|
|
||||||
|
my $ret;
|
||||||
|
my @logpathname;
|
||||||
|
|
||||||
|
foreach my $logFile (devspec2array('TYPE=FileLog')) {
|
||||||
|
my $logpath = InternalVal($logFile,'logfile','');
|
||||||
|
if ( $logpath =~ m#^(.+?)\/[\w]+\.log$# ) {
|
||||||
|
push( @logpathname, ( $1 =~ m/^$modpath\// ? $1 : './'.$1 ) ) if ( $1 ne './log' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
push( @pathname, @logpathname);
|
||||||
|
|
||||||
|
### remove double entries from pathname array
|
||||||
|
my %all=();
|
||||||
|
@all{@pathname}=1;
|
||||||
|
@pathname = keys %all;
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user