fix: Backup and restore fixes
All checks were successful
Deploy to Staging / Build Images (push) Successful in 2m20s
Deploy to Staging / Deploy to Staging (push) Successful in 28s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
All checks were successful
Deploy to Staging / Build Images (push) Successful in 2m20s
Deploy to Staging / Deploy to Staging (push) Successful in 28s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
This commit is contained in:
@@ -287,6 +287,8 @@ export class BackupRepository {
|
||||
databaseTablesCount: number;
|
||||
documentsCount: number;
|
||||
metadata: BackupMetadata;
|
||||
filename?: string;
|
||||
filePath?: string;
|
||||
}
|
||||
): Promise<BackupHistory | null> {
|
||||
const result = await this.pool.query(
|
||||
@@ -296,10 +298,20 @@ export class BackupRepository {
|
||||
database_tables_count = $2,
|
||||
documents_count = $3,
|
||||
metadata = $4,
|
||||
filename = COALESCE($5, filename),
|
||||
file_path = COALESCE($6, file_path),
|
||||
completed_at = NOW()
|
||||
WHERE id = $5
|
||||
WHERE id = $7
|
||||
RETURNING *`,
|
||||
[data.fileSizeBytes, data.databaseTablesCount, data.documentsCount, JSON.stringify(data.metadata), id]
|
||||
[
|
||||
data.fileSizeBytes,
|
||||
data.databaseTablesCount,
|
||||
data.documentsCount,
|
||||
JSON.stringify(data.metadata),
|
||||
data.filename || null,
|
||||
data.filePath || null,
|
||||
id,
|
||||
]
|
||||
);
|
||||
return result.rows.length > 0 ? this.mapHistoryRow(result.rows[0]) : null;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,10 @@ export class BackupArchiveService {
|
||||
const postgresqlVersion = versionOutput.trim().split(' ')[1] || 'unknown';
|
||||
|
||||
// Export database using pg_dump
|
||||
// --clean: Output DROP statements before CREATE (required for restore to work on existing DB)
|
||||
// --if-exists: Add IF EXISTS to DROP statements (prevents errors on fresh installs)
|
||||
await execAsync(
|
||||
`pg_dump -h ${dbHost} -p ${dbPort} -U ${dbUser} -d ${dbName} --format=plain -f "${sqlPath}"`,
|
||||
`pg_dump -h ${dbHost} -p ${dbPort} -U ${dbUser} -d ${dbName} --format=plain --clean --if-exists -f "${sqlPath}"`,
|
||||
{ env: pgEnv }
|
||||
);
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ export class BackupService {
|
||||
fileSizeBytes: result.sizeBytes,
|
||||
databaseTablesCount: result.manifest.contents.database.tablesCount,
|
||||
documentsCount: result.manifest.contents.documents.totalFiles,
|
||||
filename,
|
||||
filePath: result.archivePath,
|
||||
metadata: {
|
||||
...result.manifest.metadata,
|
||||
filename,
|
||||
|
||||
Reference in New Issue
Block a user