code styöe

This commit is contained in:
Marko Oldenburg 2019-03-28 16:40:30 +01:00
parent b0a134e779
commit 6556675b49

View File

@ -32,8 +32,10 @@ use FHEM::Meta;
##################################### #####################################
sub backup_Initialize($$) { sub backup_Initialize($$) {
my %hash = ( Fn => 'FHEM::backup::CommandBackup', my %hash = (
Hlp => ',create a backup of fhem configuration, state and modpath' ); Fn => 'FHEM::backup::CommandBackup',
Hlp => ',create a backup of fhem configuration, state and modpath'
);
$cmds{backup} = \%hash; $cmds{backup} = \%hash;
return FHEM::Meta::InitMod( __FILE__, \%hash ); return FHEM::Meta::InitMod( __FILE__, \%hash );
@ -88,7 +90,8 @@ sub CommandBackup($$) {
my $msg; my $msg;
my $ret; my $ret;
Log(1, 'NOTE: make sure you have a database backup!') if(configDBUsed()); Log( 1, 'NOTE: make sure you have a database backup!' )
if ( configDBUsed() );
# set backupdir # set backupdir
my $backupdir; my $backupdir;
@ -119,6 +122,7 @@ sub CommandBackup($$) {
} }
if ( configDBUsed() ) { if ( configDBUsed() ) {
# add configDB configuration file # add configDB configuration file
push( @pathname, 'configDB.conf' ); push( @pathname, 'configDB.conf' );
Log( 4, 'backup include: \'configDB.conf\'' ); Log( 4, 'backup include: \'configDB.conf\'' );
@ -150,6 +154,7 @@ sub parseConfig($);
sub parseConfig($) { sub parseConfig($) {
my $configfile = shift; my $configfile = shift;
# we need default value to read included files # we need default value to read included files
$configfile = $configfile ? $configfile : 'fhem.cfg'; $configfile = $configfile ? $configfile : 'fhem.cfg';
my $fh; my $fh;
@ -171,7 +176,10 @@ sub parseConfig($) {
$ret = parseConfig($1); $ret = parseConfig($1);
} }
else { else {
Log(1, 'backup configfile: ' . $1 . ' does not exists! File not included.'); Log( 1,
'backup configfile: '
. $1
. ' does not exists! File not included.' );
} }
} }
} }
@ -207,8 +215,14 @@ sub readModpath($$) {
sub createArchiv($$$) { sub createArchiv($$$) {
my ( $backupdir, $cl, $byUpdate ) = @_; my ( $backupdir, $cl, $byUpdate ) = @_;
my $backupcmd = (!defined($attr{global}{backupcmd}) ? undef : $attr{global}{backupcmd}); my $backupcmd =
my $symlink = (!defined($attr{global}{backupsymlink}) ? 'no' : $attr{global}{backupsymlink}); ( !defined( $attr{global}{backupcmd} )
? undef
: $attr{global}{backupcmd} );
my $symlink =
( !defined( $attr{global}{backupsymlink} )
? 'no'
: $attr{global}{backupsymlink} );
my $tarOpts; my $tarOpts;
my $msg; my $msg;
my $ret; my $ret;
@ -244,9 +258,10 @@ sub createArchiv($$$) {
BC_searchTelnet('backup'); BC_searchTelnet('backup');
my $tp = $defs{$BC_telnetDevice}{PORT}; my $tp = $defs{$BC_telnetDevice}{PORT};
system("($cmd; echo Backup done;". system( "($cmd; echo Backup done;"
"$^X $0 localhost:$tp 'trigger global backup done')2>&1 &"); . "$^X $0 localhost:$tp 'trigger global backup done')2>&1 &" );
return "Started the backup in the background, watch the log for details"; return
"Started the backup in the background, watch the log for details";
} }
$ret = `($cmd) 2>&1`; $ret = `($cmd) 2>&1`;