Refactor + package updates + improve local backups
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const DATABASE_TYPES = ['postgresql'];
|
||||
const VALID_CRON_STRINGS = [
|
||||
'every_minute' => '* * * * *',
|
||||
'hourly' => '0 * * * *',
|
||||
'daily' => '0 0 * * *',
|
||||
'weekly' => '0 0 * * 0',
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
@@ -24,5 +25,18 @@ function create_standalone_postgresql($environment_id, $destination_uuid): Stand
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file locally on the filesystem.
|
||||
* @param string $filename
|
||||
* @param Server $server
|
||||
* @return void
|
||||
*/
|
||||
function delete_backup_locally(string|null $filename, Server $server): void
|
||||
{
|
||||
if (empty($filename)) {
|
||||
return;
|
||||
}
|
||||
instant_remote_process(["rm -f \"{$filename}\""], $server, throwError: false);
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Nubs\RandomNameGenerator\All;
|
||||
use Poliander\Cron\CronExpression;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
function application_configuration_dir(): string
|
||||
@@ -166,3 +167,16 @@ function is_cloud(): bool
|
||||
return !config('coolify.self_hosted');
|
||||
}
|
||||
|
||||
function validate_cron_expression($expression_to_validate): bool
|
||||
{
|
||||
$isValid = false;
|
||||
$expression = new CronExpression($expression_to_validate);
|
||||
$isValid = $expression->isValid();
|
||||
|
||||
if (isset(VALID_CRON_STRINGS[$expression_to_validate])) {
|
||||
$isValid = true;
|
||||
}
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user