mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
fix getBackupExportPath
This commit is contained in:
@@ -248,9 +248,9 @@ class Setting extends NexusModel
|
||||
return self::get("permission.user_token_allowed");
|
||||
}
|
||||
|
||||
public static function getBackupExportPath(): string
|
||||
public static function getBackupExportPath(): string|null
|
||||
{
|
||||
return self::get("backup.export_path", sys_get_temp_dir());
|
||||
return self::get("backup.export_path");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class ToolRepository extends BaseRepository
|
||||
$webRoot = base_path();
|
||||
$dirName = basename($webRoot);
|
||||
$excludes = self::BACKUP_EXCLUDES;
|
||||
$baseFilename = sprintf('%s/%s.web.%s', Setting::getBackupExportPath(), $dirName, date('Ymd.His'));
|
||||
$baseFilename = sprintf('%s/%s.web.%s', Setting::getBackupExportPath() ?: sys_get_temp_dir(), $dirName, date('Ymd.His'));
|
||||
if (command_exists('tar') && ($method === 'tar' || $method === null)) {
|
||||
$filename = $baseFilename . ".tar.gz";
|
||||
$command = "tar";
|
||||
@@ -89,7 +89,7 @@ class ToolRepository extends BaseRepository
|
||||
{
|
||||
$connectionName = config('database.default');
|
||||
$config = config("database.connections.$connectionName");
|
||||
$filename = sprintf('%s/%s.database.%s.sql', Setting::getBackupExportPath(), basename(base_path()), date('Ymd.His'));
|
||||
$filename = sprintf('%s/%s.database.%s.sql', Setting::getBackupExportPath() ?: sys_get_temp_dir(), basename(base_path()), date('Ymd.His'));
|
||||
$command = sprintf(
|
||||
'mysqldump --user=%s --password=%s --host=%s --port=%s --single-transaction --no-create-db %s >> %s 2>&1',
|
||||
$config['username'], $config['password'], $config['host'], $config['port'], $config['database'], $filename,
|
||||
@@ -115,7 +115,7 @@ class ToolRepository extends BaseRepository
|
||||
if ($backupDatabase['result_code'] != 0) {
|
||||
throw new \RuntimeException("backup database fail: " . json_encode($backupDatabase));
|
||||
}
|
||||
$baseFilename = sprintf('%s/%s.%s', Setting::getBackupExportPath(), basename(base_path()), date('Ymd.His'));
|
||||
$baseFilename = sprintf('%s/%s.%s', Setting::getBackupExportPath() ?: sys_get_temp_dir(), basename(base_path()), date('Ymd.His'));
|
||||
if (command_exists('tar') && ($method === 'tar' || $method === null)) {
|
||||
$filename = $baseFilename . ".tar.gz";
|
||||
$command = sprintf(
|
||||
|
||||
Reference in New Issue
Block a user