From 3248e82d65ad21f2d46320053055f92e4742ed03 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 27 May 2021 08:49:20 +0200 Subject: [PATCH] * Setup: skip files backup on update even if configured It might takes the server down for hours and updates usually dont affect the files --- api/src/Db/Backup.php | 7 ++++--- setup/setup-cli.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/src/Db/Backup.php b/api/src/Db/Backup.php index e09132ddb5..b2304fdcfd 100644 --- a/api/src/Db/Backup.php +++ b/api/src/Db/Backup.php @@ -858,9 +858,10 @@ class Backup * @param resource $f file opened with fopen for writing * @param boolean $lock_table =null true: allways, false: never, null: if no primary key * default of null limits memory usage if there is no primary key, by locking table and use ROW_CHUCK + * @param bool $skip_files_backup =false true: do not backup files, even if config / $this->backup_files is set (used by upgrade) * @todo use https://github.com/maennchen/ZipStream-PHP to not assemble all files in memmory */ - function backup($f, $lock_table=null) + function backup($f, $lock_table=null, bool $skip_files_backup=false) { //echo "function backup($f)
"; // ! @set_time_limit(0); @@ -876,7 +877,7 @@ class Backup $name = $this->backup_dir.'/db_backup-'.date('YmdHi'); $filename = $name.'.zip'; $zippresent = false; - if(class_exists('ZipArchive') && $this->backup_files) + if(class_exists('ZipArchive') && $this->backup_files && !$skip_files_backup) { $zip = new ZipArchive; if(is_object($zip)) @@ -952,7 +953,7 @@ class Backup if(!$zippresent) // save without files { - if ($this->backup_files) + if ($this->backup_files && !$skip_files_backup) { echo '
'.lang("Cant open %1, needs ZipArchive", $name)."
\n".'
'; } diff --git a/setup/setup-cli.php b/setup/setup-cli.php index 468080fdeb..cd858914cb 100755 --- a/setup/setup-cli.php +++ b/setup/setup-cli.php @@ -257,7 +257,7 @@ function do_backup($arg,$quite_check=false) if (is_resource($f = $db_backup->fopen_backup($backup))) { echo lang('Backup started, this might take a few minutes ...')."\n"; - $db_backup->backup($f); + $db_backup->backup($f, null, true); // true: skip (configured) files backup echo lang('Backup finished')."\n"; } else // backup failed ==> dont start the upgrade