Aggiunta esclusioni da backup del db

This commit is contained in:
Luca 2024-03-03 17:52:50 +01:00
parent 7c3e8a63d4
commit 9d8f884e18
3 changed files with 33 additions and 20 deletions

View File

@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use Models\OperationLog;
include_once __DIR__.'/../../core.php';
@ -40,7 +41,7 @@ $(document).ready(function () {
loader.show();
content.html("");
content.load("'.$structure->fileurl($file).'?effettua_controllo=1", function() {
content.load("'.$structure->fileurl($file).'?effettua_controllo=1&id_module='.$id_module.'", function() {
loader.hide();
});
})
@ -71,9 +72,11 @@ foreach ($checksum as $file => $md5) {
$errors[] = $file;
}
}
OperationLog::setInfo('id_module', $id_module);
// Schermata di visualizzazione degli errori
if (!empty($errors)) {
OperationLog::setInfo('options', 'KO');
echo '
<p>'.tr("Segue l'elenco dei file che presentano checksum diverso rispetto a quello registrato nella versione ufficiale").'.</p>
<div class="alert alert-warning">
@ -105,8 +108,12 @@ if (!empty($errors)) {
</tbody>
</table>';
} else {
OperationLog::setInfo('options', 'OK');
echo '
<div class="alert alert-info">
<i class="fa fa-info-circle"></i> '.tr('Nessun file con problemi di integrità').'.
</div>';
}
OperationLog::build('effettua_controllo');

View File

@ -57,8 +57,15 @@ switch (filter('op')) {
case 'backup':
$ignore_dirs = [];
if (!empty(filter('ignore_dirs'))){
/*if (!empty(filter('ignore_dirs'))){
$ignore_dirs = explode(',', filter('ignore_dirs'));
}*/
if (filter('exclude') == 'exclude_attachments'){
$ignore_dirs[] = 'files';
}else if (filter('exclude') == 'only_database'){
$ignore_dirs = ['vendor','update','templates','src','plugins','modules','logs','locale','lib','include','files','config','assets','api'];
}
try {

View File

@ -21,6 +21,8 @@ include_once __DIR__.'/../../core.php';
$backups = Backup::getList();
// Controllo sul requisito ZIP
if (!extension_loaded('zip')) {
echo "
@ -82,25 +84,34 @@ function restore() {
}
// Creazione backup
function creaBackup(button, ignore_dirs = \'\'){
function creaBackup(button){
swal({
title: "'.tr('Nuovo backup').'",
text: "'.tr('Sei sicuro di voler creare un nuovo backup?').'",
title: "'.tr('Creare un nuovo backup?').'",
text: "'.tr('Seleziona cosa escludere dal backup:').'",
input: "select",
inputOptions: {
"exclude_attachments": "📎 '.tr('Allegati').'",
"only_database": "🗃️ '.tr('Tutto tranne database').'"
},
inputAttributes: {
title: "'.tr('Seleziona cosa escludere dal backup').'"
},
inputPlaceholder: " '.tr('Non escludere nulla').'",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn btn-lg btn-success",
confirmButtonText: "'.tr('Crea').'",
}).then(function() {
}).then(function(result) {
let restore = buttonLoading(button);
$("#main_loading").show();
let selectedOption = result;
$.ajax({
url: globals.rootdir + "/actions.php",
type: "GET",
data: {
id_module: globals.id_module,
ignore_dirs: JSON.parse(JSON.stringify(ignore_dirs)),
op: "backup",
exclude: selectedOption
},
success: function(data) {
$("#main_loading").fadeOut();
@ -321,18 +332,6 @@ if (!empty($backup_dir)) {
<a class="btn btn-primary" aria-haspopup="true" aria-expanded="false" onclick="creaBackup(this)">
<i class="fa fa-archive"></i> '.tr('Crea backup').'
</a>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a class="clickable" data-toggle="modal" data-title="'.tr('Crea backup parziale').'" onclick="creaBackup(this, \'files\')">
<i class="fa fa-database"></i>'.tr('Crea backup parziale').'
</a>
</li>
</ul>
</div>
<div class="clearfix"></div>';
}