mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-07 02:07:43 +02:00
Fix backup restore (#10943)
* Fix backup clean blobs issue Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Restore accounts Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Allow skip queue for backup-restore Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Fix backup of wrong social ids Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Filter backup logs Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Fix doRestoreWorkspace signature after accounts-restore port The 'Restore accounts' cherry-pick updated the workspace-service restore call site to pass accountsDbUrl/accountsDbNs through to doRestoreWorkspace, but doRestoreWorkspace itself was never updated to accept them (this mismatch existed in the upstream fork too and only surfaced once types were rebuilt). Extend doRestoreWorkspace to open an AccountDB from the given URL/ns, mirroring the existing doBackup pattern, and thread it into restore() so the automatic workspace-service restore flow can also restore accounts, not just the manual dev-tool CLI restore. Signed-off-by: Artyom Savchenko <armisav@gmail.com> --------- Signed-off-by: Andrey Sobolev <haiodo@gmail.com> Signed-off-by: Artyom Savchenko <armisav@gmail.com> Co-authored-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
co-authored by
Andrey Sobolev
parent
bf798c1bbc
commit
0682cd502e
+2
-2
@@ -1755,7 +1755,7 @@ export async function restoreFromv6All (
|
||||
}
|
||||
await sendTransactorEvent(uuid, 'force-maintenance')
|
||||
|
||||
await restore(ctx, pipeline, wsIds, storage, {
|
||||
await restore(ctx, pipeline, wsIds, storage, undefined, {
|
||||
date: -1,
|
||||
merge: false,
|
||||
parallel: 1,
|
||||
@@ -1928,7 +1928,7 @@ export async function restoreTrustedV6Workspace (
|
||||
}
|
||||
await sendTransactorEvent(uuid, 'force-maintenance')
|
||||
|
||||
await restore(ctx, pipeline, wsIds, backupWsStorage, {
|
||||
await restore(ctx, pipeline, wsIds, backupWsStorage, undefined, {
|
||||
date: -1,
|
||||
merge: false,
|
||||
parallel: 1,
|
||||
|
||||
+10
-6
@@ -1136,6 +1136,8 @@ export function devTool (
|
||||
.option('-i, --include <include>', 'A list of ; separated domain names to include during backup', '*')
|
||||
.option('-s, --skip <skip>', 'A list of ; separated domain names to skip during backup', '')
|
||||
.option('--upgrade', 'Upgrade workspace', false)
|
||||
.option('--noqueue', 'NoQueue', false)
|
||||
.option('--accounts', 'Restore accounts (person/socialId) from backup', false)
|
||||
.option(
|
||||
'--history-file <historyFile>',
|
||||
'Store blob send info into file. Will skip already send documents.',
|
||||
@@ -1156,6 +1158,8 @@ export function devTool (
|
||||
useStorage: string
|
||||
historyFile: string
|
||||
upgrade: boolean
|
||||
noqueue: boolean
|
||||
accounts: boolean
|
||||
}
|
||||
) => {
|
||||
await withAccountDatabase(async (db) => {
|
||||
@@ -1174,10 +1178,10 @@ export function devTool (
|
||||
const storage = await createFileBackupStorage(dirName)
|
||||
const storageConfig = storageConfigFromEnv()
|
||||
|
||||
const queue = getPlatformQueue('tool', ws.region)
|
||||
const wsProducer = queue.getProducer<QueueWorkspaceMessage>(toolCtx, QueueTopic.Workspace)
|
||||
const queue = !cmd.noqueue ? getPlatformQueue('tool', ws.region) : undefined
|
||||
const wsProducer = queue?.getProducer<QueueWorkspaceMessage>(toolCtx, QueueTopic.Workspace)
|
||||
|
||||
await wsProducer.send(toolCtx, ws.uuid, [workspaceEvents.restoring()])
|
||||
await wsProducer?.send(toolCtx, ws.uuid, [workspaceEvents.restoring()])
|
||||
|
||||
const workspaceStorage: StorageAdapter = buildStorageFromConfig(storageConfig)
|
||||
|
||||
@@ -1202,7 +1206,7 @@ export function devTool (
|
||||
}
|
||||
await sendTransactorEvent(workspace, 'force-maintenance')
|
||||
|
||||
await restore(toolCtx, pipeline, wsIds, storage, {
|
||||
await restore(toolCtx, pipeline, wsIds, storage, cmd.accounts ? db : undefined, {
|
||||
date: parseInt(date ?? '-1'),
|
||||
merge: cmd.merge,
|
||||
parallel: parseInt(cmd.parallel ?? '1'),
|
||||
@@ -1219,12 +1223,12 @@ export function devTool (
|
||||
}
|
||||
|
||||
console.log('workspace restored')
|
||||
await wsProducer.send(toolCtx, ws.uuid, [workspaceEvents.restored()])
|
||||
await wsProducer?.send(toolCtx, ws.uuid, [workspaceEvents.restored()])
|
||||
} catch (err) {
|
||||
toolCtx.error('failed to restore', { err })
|
||||
}
|
||||
await pipeline?.close()
|
||||
await queue.shutdown()
|
||||
await queue?.shutdown()
|
||||
await workspaceStorage?.close()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user