mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 23:06:05 +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:
parent
e68bf58f2b
commit
981b9faf02
@ -29,7 +29,7 @@ use warnings;
|
|||||||
sub CommandBackup($$);
|
sub CommandBackup($$);
|
||||||
sub parseConfig($);
|
sub parseConfig($);
|
||||||
sub readModpath($$);
|
sub readModpath($$);
|
||||||
sub createArchiv($);
|
sub createArchiv($$);
|
||||||
|
|
||||||
my @pathname;
|
my @pathname;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ CommandBackup($$)
|
|||||||
$ret = readModpath($modpath,$backupdir);
|
$ret = readModpath($modpath,$backupdir);
|
||||||
|
|
||||||
# create archiv
|
# create archiv
|
||||||
$ret = createArchiv($backupdir);
|
$ret = createArchiv($backupdir, $cl);
|
||||||
|
|
||||||
@pathname = [];
|
@pathname = [];
|
||||||
undef @pathname;
|
undef @pathname;
|
||||||
@ -159,9 +159,9 @@ readModpath($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
createArchiv($)
|
createArchiv($$)
|
||||||
{
|
{
|
||||||
my $backupdir = shift;
|
my ($backupdir,$cl) = @_;
|
||||||
my $backupcmd = (!defined($attr{global}{backupcmd}) ? undef : $attr{global}{backupcmd});
|
my $backupcmd = (!defined($attr{global}{backupcmd}) ? undef : $attr{global}{backupcmd});
|
||||||
my $symlink = (!defined($attr{global}{backupsymlink}) ? "no" : $attr{global}{backupsymlink});
|
my $symlink = (!defined($attr{global}{backupsymlink}) ? "no" : $attr{global}{backupsymlink});
|
||||||
my $tarOpts;
|
my $tarOpts;
|
||||||
@ -188,6 +188,10 @@ createArchiv($)
|
|||||||
|
|
||||||
}
|
}
|
||||||
Log 2, "Backup with command: $cmd";
|
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`;
|
$ret = `($cmd) 2>&1`;
|
||||||
|
|
||||||
if($ret) {
|
if($ret) {
|
||||||
|
@ -1189,7 +1189,7 @@ OpenLogfile($)
|
|||||||
$defs{global}{logfile} = $attr{global}{logfile};
|
$defs{global}{logfile} = $attr{global}{logfile};
|
||||||
|
|
||||||
open(LOG, ">>$currlogfile") || return("Can't open $currlogfile: $!");
|
open(LOG, ">>$currlogfile") || return("Can't open $currlogfile: $!");
|
||||||
redirectStdinStdErr() if($init_done);
|
redirectStdinStdErr();
|
||||||
|
|
||||||
}
|
}
|
||||||
LOG->autoflush(1);
|
LOG->autoflush(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user