feat: backup improvements
All checks were successful
Deploy to Staging / Build Images (push) Successful in 4m31s
Deploy to Staging / Deploy to Staging (push) Successful in 37s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 6s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
All checks were successful
Deploy to Staging / Build Images (push) Successful in 4m31s
Deploy to Staging / Deploy to Staging (push) Successful in 37s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 6s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
This commit is contained in:
@@ -214,11 +214,9 @@ export class BackupRestoreService {
|
||||
const pgEnv = { ...process.env, PGPASSWORD: dbPassword };
|
||||
|
||||
try {
|
||||
// Drop existing connections (except our own)
|
||||
await execAsync(
|
||||
`psql -h ${dbHost} -p ${dbPort} -U ${dbUser} -d postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${dbName}' AND pid <> pg_backend_pid();"`,
|
||||
{ env: pgEnv }
|
||||
);
|
||||
// Note: We no longer terminate connections before restore.
|
||||
// The --clean flag in pg_dump generates DROP statements that handle existing data.
|
||||
// Terminating connections would kill the backend's own pool and break the HTTP response.
|
||||
|
||||
// Restore the database using psql
|
||||
await execAsync(
|
||||
|
||||
Reference in New Issue
Block a user