mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-06-13 05:39:35 +08:00
feat(backup): 新增 MongoDB 备份与恢复支持 (#87)
通过 mongodump/mongorestore --archive 流式管线接入 MongoDB 数据源,与现有数据库运行器架构一致;注册到 Master 与 Agent,含任务校验、默认端口与前端表单/恢复确认。5 个单测覆盖参数构造、全库、空产物与缺工具分支。
This commit is contained in:
@@ -198,11 +198,11 @@ export function BackupTaskFormDrawer({ visible, loading, initialValue, storageTa
|
||||
sourcePath: value === 'file' ? current.sourcePath : '',
|
||||
sourcePaths: value === 'file' ? current.sourcePaths : [''],
|
||||
excludePatterns: value === 'file' ? current.excludePatterns : [],
|
||||
dbHost: value === 'mysql' || value === 'postgresql' || value === 'saphana' ? current.dbHost : '',
|
||||
dbPort: value === 'mysql' || value === 'postgresql' || value === 'saphana' ? current.dbPort || getDefaultPort(value) : 0,
|
||||
dbUser: value === 'mysql' || value === 'postgresql' || value === 'saphana' ? current.dbUser : '',
|
||||
dbPassword: value === 'mysql' || value === 'postgresql' || value === 'saphana' ? current.dbPassword : '',
|
||||
dbName: value === 'mysql' || value === 'postgresql' || value === 'saphana' ? current.dbName : '',
|
||||
dbHost: isDatabaseBackupTask(value) ? current.dbHost : '',
|
||||
dbPort: isDatabaseBackupTask(value) ? current.dbPort || getDefaultPort(value) : 0,
|
||||
dbUser: isDatabaseBackupTask(value) ? current.dbUser : '',
|
||||
dbPassword: isDatabaseBackupTask(value) ? current.dbPassword : '',
|
||||
dbName: isDatabaseBackupTask(value) ? current.dbName : '',
|
||||
dbPath: value === 'sqlite' ? current.dbPath : '',
|
||||
// 切换到 SAP HANA 时初始化扩展配置;切换到其他类型时清空
|
||||
extraConfig: value === 'saphana'
|
||||
|
||||
@@ -6,6 +6,7 @@ export const backupTaskTypeOptions = [
|
||||
{ label: 'SQLite', value: 'sqlite' },
|
||||
{ label: 'PostgreSQL', value: 'postgresql' },
|
||||
{ label: 'SAP HANA', value: 'saphana' },
|
||||
{ label: 'MongoDB', value: 'mongodb' },
|
||||
] as const
|
||||
|
||||
export const backupCompressionOptions = [
|
||||
@@ -25,6 +26,8 @@ export function getBackupTaskTypeLabel(type: BackupTaskType) {
|
||||
return 'PostgreSQL'
|
||||
case 'saphana':
|
||||
return 'SAP HANA'
|
||||
case 'mongodb':
|
||||
return 'MongoDB'
|
||||
default:
|
||||
return type
|
||||
}
|
||||
@@ -67,7 +70,7 @@ export function isSQLiteBackupTask(type: BackupTaskType) {
|
||||
}
|
||||
|
||||
export function isDatabaseBackupTask(type: BackupTaskType) {
|
||||
return type === 'mysql' || type === 'postgresql' || type === 'saphana'
|
||||
return type === 'mysql' || type === 'postgresql' || type === 'saphana' || type === 'mongodb'
|
||||
}
|
||||
|
||||
export function getDefaultPort(type: BackupTaskType) {
|
||||
@@ -78,6 +81,8 @@ export function getDefaultPort(type: BackupTaskType) {
|
||||
return 5432
|
||||
case 'saphana':
|
||||
return 30015
|
||||
case 'mongodb':
|
||||
return 27017
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ function renderRestoreTarget(task: BackupTaskDetail) {
|
||||
if (task.type === 'sqlite') {
|
||||
return <Typography.Text code>{task.dbPath || '-'}</Typography.Text>
|
||||
}
|
||||
if (task.type === 'mysql' || task.type === 'postgresql' || task.type === 'saphana') {
|
||||
if (task.type === 'mysql' || task.type === 'postgresql' || task.type === 'saphana' || task.type === 'mongodb') {
|
||||
return (
|
||||
<Typography.Text>
|
||||
{task.dbUser}@{task.dbHost}:{task.dbPort} / <Typography.Text code>{task.dbName || '-'}</Typography.Text>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type BackupTaskType = 'file' | 'mysql' | 'sqlite' | 'postgresql' | 'saphana'
|
||||
export type BackupTaskType = 'file' | 'mysql' | 'sqlite' | 'postgresql' | 'saphana' | 'mongodb'
|
||||
export type BackupTaskStatus = 'idle' | 'running' | 'success' | 'failed'
|
||||
export type BackupCompression = 'gzip' | 'none'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user