new deployer command
This commit is contained in:
@@ -217,9 +217,12 @@ class DatabaseStage extends Command
|
||||
$this->components->task('Restoring complete stage database', function () use ($stage, $remoteDump): bool {
|
||||
$restore = sprintf(
|
||||
'PGPASSWORD=%s pg_restore --host=%s --port=%s --username=%s --dbname=%s --no-owner --no-acl --exit-on-error --verbose %s',
|
||||
escapeshellarg((string) $stage['password']), escapeshellarg((string) $stage['db_host']),
|
||||
escapeshellarg((string) $stage['db_port']), escapeshellarg((string) $stage['username']),
|
||||
escapeshellarg((string) $stage['database']), escapeshellarg($remoteDump),
|
||||
escapeshellarg((string) $stage['password']),
|
||||
escapeshellarg((string) $stage['db_host']),
|
||||
escapeshellarg((string) $stage['db_port']),
|
||||
escapeshellarg((string) $stage['username']),
|
||||
escapeshellarg((string) $stage['database']),
|
||||
escapeshellarg($remoteDump),
|
||||
);
|
||||
$result = Process::timeout(3600)->run($this->sshCommand($stage, $restore));
|
||||
$this->throwWhenFailed($result->failed(), "Database restore failed:\n" . $result->errorOutput());
|
||||
@@ -234,8 +237,10 @@ class DatabaseStage extends Command
|
||||
$this->components->task('Verifying restored database', function () use ($stage): bool {
|
||||
$command = sprintf(
|
||||
'PGPASSWORD=%s psql --host=%s --port=%s --username=%s --dbname=%s --tuples-only --command=%s',
|
||||
escapeshellarg((string) $stage['password']), escapeshellarg((string) $stage['db_host']),
|
||||
escapeshellarg((string) $stage['db_port']), escapeshellarg((string) $stage['username']),
|
||||
escapeshellarg((string) $stage['password']),
|
||||
escapeshellarg((string) $stage['db_host']),
|
||||
escapeshellarg((string) $stage['db_port']),
|
||||
escapeshellarg((string) $stage['username']),
|
||||
escapeshellarg((string) $stage['database']),
|
||||
escapeshellarg("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public';"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user