Allow to backup and skip domain (#4077)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-11-27 22:46:52 +07:00 committed by GitHub
parent 704503ef12
commit fb4cdfba5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -342,9 +342,15 @@ export function devTool (
program
.command('backup <dirName> <workspace>')
.description('dump workspace transactions and minio resources')
.action(async (dirName: string, workspace: string, cmd) => {
.option('-s, --skip <skip>', 'A list of ; separated domain names to skip during backup', '')
.action(async (dirName: string, workspace: string, cmd: { skip: string }) => {
const storage = await createFileBackupStorage(dirName)
await backup(transactorUrl, getWorkspaceId(workspace, productId), storage)
await backup(
transactorUrl,
getWorkspaceId(workspace, productId),
storage,
(cmd.skip ?? '').split(';').map((it) => it.trim())
)
})
program

View File

@ -327,7 +327,12 @@ export async function cloneWorkspace (
/**
* @public
*/
export async function backup (transactorUrl: string, workspaceId: WorkspaceId, storage: BackupStorage): Promise<void> {
export async function backup (
transactorUrl: string,
workspaceId: WorkspaceId,
storage: BackupStorage,
skipDomains: string[] = []
): Promise<void> {
const connection = (await connect(transactorUrl, workspaceId, undefined, {
mode: 'backup'
})) as unknown as CoreClient & BackupClient
@ -337,7 +342,7 @@ export async function backup (transactorUrl: string, workspaceId: WorkspaceId, s
...connection
.getHierarchy()
.domains()
.filter((it) => it !== DOMAIN_TRANSIENT && it !== DOMAIN_MODEL)
.filter((it) => it !== DOMAIN_TRANSIENT && it !== DOMAIN_MODEL && !skipDomains.includes(it))
]
console.log('domains for dump', domains.length)