2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-28 02:44:53 +00:00

98_backup.pm: execute in the background if called from FHEMWEB to avoid double execution

git-svn-id: https://svn.fhem.de/fhem/trunk@8810 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-06-23 18:40:53 +00:00
parent e68bf58f2b
commit 981b9faf02
2 changed files with 9 additions and 5 deletions

@ -29,7 +29,7 @@ use warnings;
sub CommandBackup($$);
sub parseConfig($);
sub readModpath($$);
sub createArchiv($);
sub createArchiv($$);
my @pathname;
@ -96,7 +96,7 @@ CommandBackup($$)
$ret = readModpath($modpath,$backupdir);
# create archiv
$ret = createArchiv($backupdir);
$ret = createArchiv($backupdir, $cl);
@pathname = [];
undef @pathname;
@ -159,9 +159,9 @@ readModpath($$)
}
sub
createArchiv($)
createArchiv($$)
{
my $backupdir = shift;
my ($backupdir,$cl) = @_;
my $backupcmd = (!defined($attr{global}{backupcmd}) ? undef : $attr{global}{backupcmd});
my $symlink = (!defined($attr{global}{backupsymlink}) ? "no" : $attr{global}{backupsymlink});
my $tarOpts;
@ -188,6 +188,10 @@ createArchiv($)
}
Log 2, "Backup with command: $cmd";
if($cl && ref($cl) eq "HASH" && $cl->{TYPE} && $cl->{TYPE} eq "FHEMWEB") {
system("($cmd; echo Backup done) 2>&1 &");
return "Started the backup in the background, watch the log for details";
}
$ret = `($cmd) 2>&1`;
if($ret) {

@ -1189,7 +1189,7 @@ OpenLogfile($)
$defs{global}{logfile} = $attr{global}{logfile};
open(LOG, ">>$currlogfile") || return("Can't open $currlogfile: $!");
redirectStdinStdErr() if($init_done);
redirectStdinStdErr();
}
LOG->autoflush(1);