Skip to content

Commit b443431

Browse files
author
Marius Burkard
committed
Merge branch '5878-some-domain-s-aren-t-backed-up' into 'develop'
Resolve "Some domain's aren't backed up" Closes #5878 See merge request ispconfig/ispconfig3!1324
2 parents 931731d + 3c2c55d commit b443431

File tree

2 files changed

+154
-17
lines changed

2 files changed

+154
-17
lines changed

interface/web/sites/form/web_vhost_domain.tform.php

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -640,24 +640,51 @@
640640

641641
//* Backup
642642
if ($backup_available) {
643+
644+
$domain_server_id = null;
645+
if(isset($_REQUEST["id"])) {
646+
$domain_id = $app->functions->intval($_REQUEST["id"]);
647+
if($domain_id) {
648+
$domain_data = $app->db->queryOneRecord('SELECT `server_id` FROM `web_domain` WHERE `domain_id` = ?', $domain_id);
649+
if($domain_data) {
650+
$domain_server_id = $domain_data['server_id'];
651+
}
652+
}
653+
}
654+
if(!$domain_server_id) {
655+
$domain_server_id = $conf['server_id'];
656+
}
657+
643658
$missing_utils = array();
644-
$compressors_list = array(
645-
'gzip',
646-
'gunzip',
647-
'zip',
648-
'unzip',
649-
'pigz',
650-
'tar',
651-
'bzip2',
652-
'bunzip2',
653-
'xz',
654-
'unxz',
655-
'7z',
656-
'rar',
657-
);
658-
foreach ($compressors_list as $compressor) {
659-
if (!$app->system->is_installed($compressor)) {
660-
array_push($missing_utils, $compressor);
659+
if($domain_server_id != $conf['server_id']) {
660+
$mon = $app->db->queryOneRecord('SELECT `data` FROM `monitor_data` WHERE `server_id` = ? AND `type` = ? ORDER BY `created` DESC', $domain_server_id, 'backup_utils');
661+
if($mon) {
662+
$missing_utils = unserialize($mon['data']);
663+
if(!$missing_utils) {
664+
$missing_utils = array();
665+
} else {
666+
$missing_utils = $missing_utils['missing_utils'];
667+
}
668+
}
669+
} else {
670+
$compressors_list = array(
671+
'gzip',
672+
'gunzip',
673+
'zip',
674+
'unzip',
675+
'pigz',
676+
'tar',
677+
'bzip2',
678+
'bunzip2',
679+
'xz',
680+
'unxz',
681+
'7z',
682+
'rar',
683+
);
684+
foreach ($compressors_list as $compressor) {
685+
if (!$app->system->is_installed($compressor)) {
686+
array_push($missing_utils, $compressor);
687+
}
661688
}
662689
}
663690
$app->tpl->setVar("missing_utils", implode(", ",$missing_utils), true);
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2013, Marius Cramer, pixcept KG
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
class cronjob_monitor_backup extends cronjob {
32+
33+
// job schedule
34+
protected $_schedule = '*/5 * * * *';
35+
protected $_run_at_new = true;
36+
37+
private $_tools = null;
38+
39+
/* this function is optional if it contains no custom code */
40+
public function onPrepare() {
41+
parent::onPrepare();
42+
}
43+
44+
/* this function is optional if it contains no custom code */
45+
public function onBeforeRun() {
46+
return parent::onBeforeRun();
47+
}
48+
49+
public function onRunJob() {
50+
global $app, $conf;
51+
52+
/* used for all monitor cronjobs */
53+
$app->load('monitor_tools');
54+
$this->_tools = new monitor_tools();
55+
/* end global section for monitor cronjobs */
56+
57+
/* the id of the server as int */
58+
$server_id = intval($conf['server_id']);
59+
60+
/** The type of the data */
61+
62+
63+
$type = 'backup_utils';
64+
65+
$missing_utils = array();
66+
$compressors_list = array(
67+
'gzip',
68+
'gunzip',
69+
'zip',
70+
'unzip',
71+
'pigz',
72+
'tar',
73+
'bzip2',
74+
'bunzip2',
75+
'xz',
76+
'unxz',
77+
'7z',
78+
'rar',
79+
);
80+
foreach ($compressors_list as $compressor) {
81+
if (!$app->system->is_installed($compressor)) {
82+
$missing_utils[] = $compressor;
83+
}
84+
}
85+
86+
$res = array();
87+
$res['server_id'] = $server_id;
88+
$res['type'] = $type;
89+
$res['data'] = array('missing_utils' => $missing_utils);
90+
$res['state'] = 'ok';
91+
92+
/*
93+
* Insert the data into the database
94+
*/
95+
$sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' .
96+
'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)';
97+
$app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']);
98+
99+
/* The new data is written, now we can delete the old one */
100+
$this->_tools->delOldRecords($res['type'], $res['server_id']);
101+
102+
parent::onRunJob();
103+
}
104+
105+
/* this function is optional if it contains no custom code */
106+
public function onAfterRun() {
107+
parent::onAfterRun();
108+
}
109+
110+
}

0 commit comments

Comments
 (0)