Open fiedsch opened 9 months ago
Maybe use something like the following extract a parameter from the DATABASE_URL:
DATABASE_URL
<?php require ('/path/to/the/contao/installation/we/want/to/backup/vendor/autoload.php'); use Doctrine\DBAL\Tools\DsnParser; use Doctrine\DBAL\Exception\MalformedDsnException; $dsn = $argv[1] ?? ''; $parameter = $argv[2] ?? ''; if ('' === $dsn || '' === $parameter) { fwrite(STDERR, 'required parameters are missing'); exit(1); } $dsnParser = new DsnParser(); try { $connectionParams = $dsnParser->parse($dsn); } catch (MalformedDsnException $e) { fwrite(STDERR, $e->getMessage()); exit(2); } if (!isset($connectionParams['port'])) { $connectionParams['port'] = 3306; } if (!isset($connectionParams[$parameter])) { fwrite(STDERR, 'parameter not set'); exit(3); } echo $connectionParams[$parameter]; exit(0);
Maybe use something like the following extract a parameter from the
DATABASE_URL
: