Aggiunto backup del solo database

This commit is contained in:
Luca 2024-03-04 02:07:58 +01:00
parent fd7a021605
commit 04f0d8a20c
2 changed files with 11 additions and 19 deletions

View File

@ -56,20 +56,16 @@ switch (filter('op')) {
case 'backup':
$ignore_dirs = [];
/*if (!empty(filter('ignore_dirs'))){
$ignore_dirs = explode(',', filter('ignore_dirs'));
}*/
$ignores = ['dirs' => [], 'files' => []];
if (filter('exclude') == 'exclude_attachments'){
$ignore_dirs[] = 'files';
$ignores = ['dirs' => ['files']];
}else if (filter('exclude') == 'only_database'){
$ignore_dirs = ['vendor','update','templates','src','plugins','modules','logs','locale','lib','include','files','config','assets','api'];
$ignores = ['dirs' => ['vendor','update','templates','src','plugins','modules','logs','locale','lib','include','files','config','assets','api'], 'files' => ['*.php','*.md','*.json','*.js','*.xml','.*']];
}
try {
$result = Backup::create($ignore_dirs);
$result = Backup::create($ignores);
if ($result) {
flash()->info(tr('Nuovo backup creato correttamente!'));

View File

@ -145,16 +145,16 @@ class Backup
/**
* Esegue il backup del progetto.
*
* @param array $ignore_dirs Eventuali dirs da ignorare
* @param array $ignores eventuali dirs o files da ignorare
*
* @return bool
*/
public static function create($ignore_dirs)
public static function create($ignores)
{
self::checkSpace();
$backup_dir = self::getDirectory();
$backup_name = tr(self::getNextName(), [ 'AAAAAAA' => ($ignore_dirs)? 'PARTIAL' : 'FULL' ]);
$backup_name = tr(self::getNextName(), [ 'AAAAAAA' => ($ignores['dirs'] || $ignores['files'] )? 'PARTIAL' : 'FULL' ]);
set_time_limit(0);
@ -162,8 +162,8 @@ class Backup
$database_file = self::getDatabaseDirectory().'/database.sql';
self::database($database_file);
// Percorsi da ignorare di default
$ignores = [
// Files e dirs da ignorare di default
$default_ignores = [
'files' => [
'config.inc.php',
'*.lock',
@ -179,13 +179,9 @@ class Backup
],
];
// Altri percorsi da ignorare
if ($ignore_dirs){
foreach ((array) $ignore_dirs as $value) {
$ignores['dirs'][] = basename($value);
}
}
$ignores = array_merge_recursive($ignores, $default_ignores);
// Escludo la directory dei backup
if (string_starts_with($backup_dir, slashes(base_dir()))) {
$ignores['dirs'][] = basename($backup_dir);
}