diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 763edbe258..e8f8c815a0 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -787,7 +787,12 @@ export function devTool ( const skipped = new Set(cmd.skip.split(',').map((it) => it.trim())) await withAccountDatabase(async (db) => { const workspaces = (await listWorkspacesPure(db)) - .sort((a, b) => a.lastVisit - b.lastVisit) + .sort((a, b) => { + const bsize = b.backupInfo?.backupSize ?? 0 + const asize = a.backupInfo?.backupSize ?? 0 + return bsize - asize + }) + .filter((it) => isActiveMode(it.mode)) .filter((it) => (cmd.workspace === '' || cmd.workspace === it.workspace) && !skipped.has(it.workspace)) let processed = 0 diff --git a/server/workspace-service/src/service.ts b/server/workspace-service/src/service.ts index 2e6a365dcf..af2fefeab7 100644 --- a/server/workspace-service/src/service.ts +++ b/server/workspace-service/src/service.ts @@ -450,7 +450,7 @@ export class WorkspaceWorker { await sendEvent('archiving-backup-started', 0) await this.sendTransactorMaitenance(token, { name: workspace.workspace }) - if (await this.doBackup(ctx, workspace, opt)) { + if (await this.doBackup(ctx, workspace, opt, true)) { await sendEvent('archiving-backup-done', 100) } break @@ -487,7 +487,7 @@ export class WorkspaceWorker { case 'migration-backup': await sendEvent('migrate-backup-started', 0) await this.sendTransactorMaitenance(token, { name: workspace.workspace }) - if (await this.doBackup(ctx, workspace, opt)) { + if (await this.doBackup(ctx, workspace, opt, false)) { await sendEvent('migrate-backup-done', 100) } break @@ -522,7 +522,12 @@ export class WorkspaceWorker { } } - private async doBackup (ctx: MeasureContext, workspace: BaseWorkspaceInfo, opt: WorkspaceOptions): Promise { + private async doBackup ( + ctx: MeasureContext, + workspace: BaseWorkspaceInfo, + opt: WorkspaceOptions, + doFullCheck: boolean + ): Promise { if (opt.backup === undefined) { return false } @@ -583,7 +588,7 @@ export class WorkspaceWorker { 50000, ['blob'], sharedPipelineContextVars, - true, // Do a full check + doFullCheck, // Do full check based on config, do not do for migration, it is to slow, will perform before migration. (_p: number) => { if (progress !== Math.round(_p)) { progress = Math.round(_p)