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;
|
databaseTablesCount: number;
|
||||||
documentsCount: number;
|
documentsCount: number;
|
||||||
metadata: BackupMetadata;
|
metadata: BackupMetadata;
|
||||||
|
filename?: string;
|
||||||
|
filePath?: string;
|
||||||
}
|
}
|
||||||
): Promise<BackupHistory | null> {
|
): Promise<BackupHistory | null> {
|
||||||
const result = await this.pool.query(
|
const result = await this.pool.query(
|
||||||
@@ -296,10 +298,20 @@ export class BackupRepository {
|
|||||||
database_tables_count = $2,
|
database_tables_count = $2,
|
||||||
documents_count = $3,
|
documents_count = $3,
|
||||||
metadata = $4,
|
metadata = $4,
|
||||||
|
filename = COALESCE($5, filename),
|
||||||
|
file_path = COALESCE($6, file_path),
|
||||||
completed_at = NOW()
|
completed_at = NOW()
|
||||||
WHERE id = $5
|
WHERE id = $7
|
||||||
RETURNING *`,
|
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;
|
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';
|
const postgresqlVersion = versionOutput.trim().split(' ')[1] || 'unknown';
|
||||||
|
|
||||||
// Export database using pg_dump
|
// 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(
|
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 }
|
{ env: pgEnv }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ export class BackupService {
|
|||||||
fileSizeBytes: result.sizeBytes,
|
fileSizeBytes: result.sizeBytes,
|
||||||
databaseTablesCount: result.manifest.contents.database.tablesCount,
|
databaseTablesCount: result.manifest.contents.database.tablesCount,
|
||||||
documentsCount: result.manifest.contents.documents.totalFiles,
|
documentsCount: result.manifest.contents.documents.totalFiles,
|
||||||
|
filename,
|
||||||
|
filePath: result.archivePath,
|
||||||
metadata: {
|
metadata: {
|
||||||
...result.manifest.metadata,
|
...result.manifest.metadata,
|
||||||
filename,
|
filename,
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ You are a senior software engineer specializsing in NodeJS, Typescript, front en
|
|||||||
- Research this code base and ask iterative questions to compile a complete plan.
|
- Research this code base and ask iterative questions to compile a complete plan.
|
||||||
- We will pair troubleshoot this. Tell me what logs and things to run and I will
|
- We will pair troubleshoot this. Tell me what logs and things to run and I will
|
||||||
- There is a backup system built into the admin settings.
|
- There is a backup system built into the admin settings.
|
||||||
- Schedules have been configured but it doesn't appear to be removing old backups
|
- Uploading a backup to restore throws a 400 API error.
|
||||||
- The hourly schedule is set to retain 8 backups but it has over 9 saved.
|
|
||||||
- It is also creating multiple backups per run.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*** ROLE ***
|
*** ROLE ***
|
||||||
|
|||||||
Reference in New Issue
Block a user