feat: 添加系统备份功能,权限控制分配

This commit is contained in:
TsMask
2025-09-19 12:01:27 +08:00
parent 11e884174c
commit adda53889f
16 changed files with 388 additions and 95 deletions

View File

@@ -969,11 +969,14 @@ INSERT INTO "sys_i18n" VALUES (789, 'menu.common.rollback', '回滚', 'Rollback'
INSERT INTO "sys_i18n" VALUES (790, 'menu.common.ftp', 'FTP 配置', 'FTP Config');
INSERT INTO "sys_i18n" VALUES (791, 'menu.common.ftpSync', 'FTP 同步', 'FTP Synchronization');
INSERT INTO "sys_i18n" VALUES (792, 'job.backup_export_kpi', '备份-KPI数据定期导出', 'Backup-Periodic export of KPI Data');
INSERT INTO "sys_i18n" VALUES (643, 'job.backup_export_kpi_remark', 'dataType: 类型支持 ims/amf/udm/smf/pcf/upf/mme/smsc
INSERT INTO "sys_i18n" VALUES (793, 'job.backup_export_kpi_remark', 'dataType: 类型支持 ims/amf/udm/smf/pcf/upf/mme/smsc
fileType: 文件类型 csv/xlsx
hour: 数据时间从任务执行时间前的小时数', 'Backup-Periodic export of dataType: type support ims/amf/udm/smf/pcf/upf/mme/smsc
fileType: file type csv/xlsx
hour: data time from the hour before the task execution time');
INSERT INTO "sys_i18n" VALUES (794, 'menu.system.setting.homeSet', '主页设置', 'Home Set');
INSERT INTO "sys_i18n" VALUES (795, 'menu.system.setting.reset', '重置', 'Reset');
INSERT INTO "sys_i18n" VALUES (796, 'menu.system.setting.backup', '备份还原', 'Backup Restore');
INSERT INTO "sys_i18n" VALUES (2000, 'menu.psap.agent', '座席', 'Agent');
INSERT INTO "sys_i18n" VALUES (2001, 'menu.psap.agent.callings', '并行话务', 'Calling Information');

View File

@@ -136,8 +136,8 @@ INSERT INTO "sys_menu" VALUES (1079, 'menu.common.stop', 2086, 3, '', '', '1', '
INSERT INTO "sys_menu" VALUES (1080, 'menu.common.reload', 2086, 4, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:textlog', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
INSERT INTO "sys_menu" VALUES (1081, 'menu.common.download', 2086, 5, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:download', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
INSERT INTO "sys_menu" VALUES (1082, 'menu.common.query', 2163, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:search', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- INSERT INTO "sys_menu" VALUES (1083, 'menu.common.edit', 2163, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:edit', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- INSERT INTO "sys_menu" VALUES (1084, 'menu.common.example', 2163, 2, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:example', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
INSERT INTO "sys_menu" VALUES (1083, 'menu.system.setting.backup', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:backup', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
INSERT INTO "sys_menu" VALUES (1084, 'menu.system.setting.reset', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:reset', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
INSERT INTO "sys_menu" VALUES (1085, 'menu.common.query', 2164, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:search', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
INSERT INTO "sys_menu" VALUES (1086, 'menu.common.start', 2164, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:start', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
INSERT INTO "sys_menu" VALUES (1087, 'menu.common.stop', 2164, 3, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:stop', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
@@ -147,7 +147,7 @@ INSERT INTO "sys_menu" VALUES (1090, 'menu.common.oam', 2137, 2, '', '', '1', '1
INSERT INTO "sys_menu" VALUES (1091, 'menu.common.delete', 2137, 3, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:delete', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO "sys_menu" VALUES (1092, 'menu.common.edit', 2137, 4, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:edit', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO "sys_menu" VALUES (1093, 'menu.common.restart', 2137, 5, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:restart', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
-- INSERT INTO "sys_menu" VALUES (1094, 'menu.common.log', 2137, 6, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:log', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO "sys_menu" VALUES (1094, 'menu.system.setting.homeSet', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:homeSet', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
INSERT INTO "sys_menu" VALUES (1095, 'menu.common.start', 2137, 7, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:start', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO "sys_menu" VALUES (1096, 'menu.common.stop', 2137, 8, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:stop', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO "sys_menu" VALUES (1097, 'menu.common.import', 2137, 9, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:import', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');

View File

@@ -103,6 +103,8 @@ INSERT INTO "sys_role_menu" VALUES (2, 1079);
INSERT INTO "sys_role_menu" VALUES (2, 1080);
INSERT INTO "sys_role_menu" VALUES (2, 1081);
INSERT INTO "sys_role_menu" VALUES (2, 1082);
INSERT INTO "sys_role_menu" VALUES (2, 1083);
INSERT INTO "sys_role_menu" VALUES (2, 1084);
INSERT INTO "sys_role_menu" VALUES (2, 1085);
INSERT INTO "sys_role_menu" VALUES (2, 1086);
INSERT INTO "sys_role_menu" VALUES (2, 1087);
@@ -112,6 +114,7 @@ INSERT INTO "sys_role_menu" VALUES (2, 1090);
INSERT INTO "sys_role_menu" VALUES (2, 1091);
INSERT INTO "sys_role_menu" VALUES (2, 1092);
INSERT INTO "sys_role_menu" VALUES (2, 1093);
INSERT INTO "sys_role_menu" VALUES (2, 1094);
INSERT INTO "sys_role_menu" VALUES (2, 1095);
INSERT INTO "sys_role_menu" VALUES (2, 1096);
INSERT INTO "sys_role_menu" VALUES (2, 1097);

View File

@@ -968,11 +968,14 @@ REPLACE INTO "sys_i18n" VALUES (789, 'menu.common.rollback', '回滚', 'Rollback
REPLACE INTO "sys_i18n" VALUES (790, 'menu.common.ftp', 'FTP 配置', 'FTP Config');
REPLACE INTO "sys_i18n" VALUES (791, 'menu.common.ftpSync', 'FTP 同步', 'FTP Synchronization');
REPLACE INTO "sys_i18n" VALUES (792, 'job.backup_export_kpi', '备份-KPI数据定期导出', 'Backup-Periodic export of KPI Data');
REPLACE INTO "sys_i18n" VALUES (643, 'job.backup_export_kpi_remark', 'dataType: 类型支持 ims/amf/udm/smf/pcf/upf/mme/smsc
REPLACE INTO "sys_i18n" VALUES (793, 'job.backup_export_kpi_remark', 'dataType: 类型支持 ims/amf/udm/smf/pcf/upf/mme/smsc
fileType: 文件类型 csv/xlsx
hour: 数据时间从任务执行时间前的小时数', 'Backup-Periodic export of dataType: type support ims/amf/udm/smf/pcf/upf/mme/smsc
fileType: file type csv/xlsx
hour: data time from the hour before the task execution time');
REPLACE INTO "sys_i18n" VALUES (794, 'menu.system.setting.homeSet', '主页设置', 'Home Set');
REPLACE INTO "sys_i18n" VALUES (795, 'menu.system.setting.reset', '重置', 'Reset');
REPLACE INTO "sys_i18n" VALUES (796, 'menu.system.setting.backup', '备份还原', 'Backup Restore');
REPLACE INTO "sys_i18n" VALUES (2000, 'menu.psap.agent', '座席', 'Agent');
REPLACE INTO "sys_i18n" VALUES (2001, 'menu.psap.agent.callings', '并行话务', 'Calling Information');

View File

@@ -135,8 +135,8 @@ REPLACE INTO "sys_menu" VALUES (1079, 'menu.common.stop', 2086, 3, '', '', '1',
REPLACE INTO "sys_menu" VALUES (1080, 'menu.common.reload', 2086, 4, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:textlog', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
REPLACE INTO "sys_menu" VALUES (1081, 'menu.common.download', 2086, 5, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:download', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
REPLACE INTO "sys_menu" VALUES (1082, 'menu.common.query', 2163, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:search', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- REPLACE INTO "sys_menu" VALUES (1083, 'menu.common.edit', 2163, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:edit', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- REPLACE INTO "sys_menu" VALUES (1084, 'menu.common.example', 2163, 2, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:example', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
REPLACE INTO "sys_menu" VALUES (1083, 'menu.system.setting.backup', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:backup', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
REPLACE INTO "sys_menu" VALUES (1084, 'menu.system.setting.reset', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:reset', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
REPLACE INTO "sys_menu" VALUES (1085, 'menu.common.query', 2164, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:search', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
REPLACE INTO "sys_menu" VALUES (1086, 'menu.common.start', 2164, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:start', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
REPLACE INTO "sys_menu" VALUES (1087, 'menu.common.stop', 2164, 3, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:stop', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
@@ -146,7 +146,7 @@ REPLACE INTO "sys_menu" VALUES (1090, 'menu.common.oam', 2137, 2, '', '', '1', '
REPLACE INTO "sys_menu" VALUES (1091, 'menu.common.delete', 2137, 3, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:delete', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO "sys_menu" VALUES (1092, 'menu.common.edit', 2137, 4, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:edit', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO "sys_menu" VALUES (1093, 'menu.common.restart', 2137, 5, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:restart', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
-- REPLACE INTO "sys_menu" VALUES (1094, 'menu.common.log', 2137, 6, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:log', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO "sys_menu" VALUES (1094, 'menu.system.setting.homeSet', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:homeSet', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
REPLACE INTO "sys_menu" VALUES (1095, 'menu.common.start', 2137, 7, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:start', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO "sys_menu" VALUES (1096, 'menu.common.stop', 2137, 8, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:stop', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO "sys_menu" VALUES (1097, 'menu.common.import', 2137, 9, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:import', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');

View File

@@ -103,6 +103,8 @@ INSERT INTO "sys_role_menu" VALUES (2, 1079);
INSERT INTO "sys_role_menu" VALUES (2, 1080);
INSERT INTO "sys_role_menu" VALUES (2, 1081);
INSERT INTO "sys_role_menu" VALUES (2, 1082);
INSERT INTO "sys_role_menu" VALUES (2, 1083);
INSERT INTO "sys_role_menu" VALUES (2, 1084);
INSERT INTO "sys_role_menu" VALUES (2, 1085);
INSERT INTO "sys_role_menu" VALUES (2, 1086);
INSERT INTO "sys_role_menu" VALUES (2, 1087);
@@ -112,6 +114,7 @@ INSERT INTO "sys_role_menu" VALUES (2, 1090);
INSERT INTO "sys_role_menu" VALUES (2, 1091);
INSERT INTO "sys_role_menu" VALUES (2, 1092);
INSERT INTO "sys_role_menu" VALUES (2, 1093);
INSERT INTO "sys_role_menu" VALUES (2, 1094);
INSERT INTO "sys_role_menu" VALUES (2, 1095);
INSERT INTO "sys_role_menu" VALUES (2, 1096);
INSERT INTO "sys_role_menu" VALUES (2, 1097);

View File

@@ -808,6 +808,9 @@ INSERT INTO `sys_i18n` VALUES (790, 'menu.common.ftp', 'FTP 配置', 'FTP Config
INSERT INTO `sys_i18n` VALUES (791, 'menu.common.ftpSync', 'FTP 同步', 'FTP Synchronization');
INSERT INTO `sys_i18n` VALUES (792, 'job.backup_export_kpi', '备份-KPI数据定期导出', 'Backup-Periodic export of KPI Data');
INSERT INTO `sys_i18n` VALUES (793, 'job.backup_export_kpi_remark', 'dataType: 类型支持 ims/smf/sgwc/smsc\nfileType: 文件类型 csv/xlsx\nhour: 数据时间从任务执行时间前的小时数', 'dataType: type support ims/smf/sgwc/smsc\nfileType: file type csv/xlsx\nhour: data time from the hour before the task execution time');
INSERT INTO `sys_i18n` VALUES (794, 'menu.system.setting.homeSet', '主页设置', 'Home Set');
INSERT INTO `sys_i18n` VALUES (795, 'menu.system.setting.reset', '重置', 'Reset');
INSERT INTO `sys_i18n` VALUES (796, 'menu.system.setting.backup', '备份还原', 'Backup Restore');
INSERT INTO `sys_i18n` VALUES (2000, 'menu.psap.agent', '座席', 'Agent');
INSERT INTO `sys_i18n` VALUES (2001, 'menu.psap.agent.callings', '并行话务', 'Calling Information');

View File

@@ -139,8 +139,8 @@ INSERT INTO `sys_menu` VALUES (1079, 'menu.common.stop', 2086, 3, '', '', '1', '
INSERT INTO `sys_menu` VALUES (1080, 'menu.common.reload', 2086, 4, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:textlog', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
INSERT INTO `sys_menu` VALUES (1081, 'menu.common.download', 2086, 5, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:download', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
INSERT INTO `sys_menu` VALUES (1082, 'menu.common.query', 2163, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:search', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- INSERT INTO `sys_menu` VALUES (1083, 'menu.common.edit', 2163, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:edit', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- INSERT INTO `sys_menu` VALUES (1084, 'menu.common.example', 2163, 2, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:example', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
INSERT INTO `sys_menu` VALUES (1083, 'menu.system.setting.backup', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:backup', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
INSERT INTO `sys_menu` VALUES (1084, 'menu.system.setting.reset', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:reset', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
INSERT INTO `sys_menu` VALUES (1085, 'menu.common.query', 2164, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:search', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
INSERT INTO `sys_menu` VALUES (1086, 'menu.common.start', 2164, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:start', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
INSERT INTO `sys_menu` VALUES (1087, 'menu.common.stop', 2164, 3, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:stop', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
@@ -150,7 +150,7 @@ INSERT INTO `sys_menu` VALUES (1090, 'menu.common.oam', 2137, 2, '', '', '1', '1
INSERT INTO `sys_menu` VALUES (1091, 'menu.common.delete', 2137, 3, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:delete', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO `sys_menu` VALUES (1092, 'menu.common.edit', 2137, 4, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:edit', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO `sys_menu` VALUES (1093, 'menu.common.restart', 2137, 5, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:restart', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
-- INSERT INTO `sys_menu` VALUES (1094, 'menu.common.log', 2137, 6, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:log', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO `sys_menu` VALUES (1094, 'menu.system.setting.homeSet', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:homeSet', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
INSERT INTO `sys_menu` VALUES (1095, 'menu.common.start', 2137, 7, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:start', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO `sys_menu` VALUES (1096, 'menu.common.stop', 2137, 8, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:stop', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
INSERT INTO `sys_menu` VALUES (1097, 'menu.common.import', 2137, 9, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:import', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');

View File

@@ -103,6 +103,8 @@ INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1079);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1080);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1081);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1082);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1083);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1084);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1085);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1086);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1087);
@@ -112,6 +114,7 @@ INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1090);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1091);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1092);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1093);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1094);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1095);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1096);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1097);

View File

@@ -805,6 +805,9 @@ REPLACE INTO `sys_i18n` VALUES (790, 'menu.common.ftp', 'FTP 配置', 'FTP Confi
REPLACE INTO `sys_i18n` VALUES (791, 'menu.common.ftpSync', 'FTP 同步', 'FTP Synchronization');
REPLACE INTO `sys_i18n` VALUES (792, 'job.backup_export_kpi', '备份-KPI数据定期导出', 'Backup-Periodic export of KPI Data');
REPLACE INTO `sys_i18n` VALUES (793, 'job.backup_export_kpi_remark', 'dataType: 类型支持 ims/smf/sgwc/smsc\nfileType: 文件类型 csv/xlsx\nhour: 数据时间从任务执行时间前的小时数', 'dataType: type support ims/smf/sgwc/smsc\nfileType: file type csv/xlsx\nhour: data time from the hour before the task execution time');
REPLACE INTO `sys_i18n` VALUES (794, 'menu.system.setting.homeSet', '主页设置', 'Home Set');
REPLACE INTO `sys_i18n` VALUES (795, 'menu.system.setting.reset', '重置', 'Reset');
REPLACE INTO `sys_i18n` VALUES (796, 'menu.system.setting.backup', '备份还原', 'Backup Restore');
REPLACE INTO `sys_i18n` VALUES (2000, 'menu.psap.agent', '座席', 'Agent');
REPLACE INTO `sys_i18n` VALUES (2001, 'menu.psap.agent.callings', '并行话务', 'Calling Information');

View File

@@ -161,8 +161,8 @@ REPLACE INTO `sys_menu` VALUES (1079, 'menu.common.stop', 2086, 3, '', '', '1',
REPLACE INTO `sys_menu` VALUES (1080, 'menu.common.reload', 2086, 4, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:textlog', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
REPLACE INTO `sys_menu` VALUES (1081, 'menu.common.download', 2086, 5, '', '', '1', '1', 'B', '1', '1', 'traceManage:pcap:download', '#', '0', 'supervisor', 1757576647815, 'supervisor', 1757576647815, '');
REPLACE INTO `sys_menu` VALUES (1082, 'menu.common.query', 2163, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:search', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- REPLACE INTO `sys_menu` VALUES (1083, 'menu.common.edit', 2163, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:edit', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
-- REPLACE INTO `sys_menu` VALUES (1084, 'menu.common.example', 2163, 2, '', '', '1', '1', 'B', '1', '1', 'traceManage:tshark:example', '#', '0', 'supervisor', 1757667388112, 'supervisor', 1757667388112, '');
REPLACE INTO `sys_menu` VALUES (1083, 'menu.system.setting.backup', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:backup', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
REPLACE INTO `sys_menu` VALUES (1084, 'menu.system.setting.reset', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:reset', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
REPLACE INTO `sys_menu` VALUES (1085, 'menu.common.query', 2164, 0, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:search', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
REPLACE INTO `sys_menu` VALUES (1086, 'menu.common.start', 2164, 1, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:start', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
REPLACE INTO `sys_menu` VALUES (1087, 'menu.common.stop', 2164, 3, '', '', '1', '1', 'B', '1', '1', 'traceManage:wireshark:stop', '#', '0', 'supervisor', 1757667601966, 'supervisor', 1757667601966, '');
@@ -172,7 +172,7 @@ REPLACE INTO `sys_menu` VALUES (1090, 'menu.common.oam', 2137, 2, '', '', '1', '
REPLACE INTO `sys_menu` VALUES (1091, 'menu.common.delete', 2137, 3, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:delete', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO `sys_menu` VALUES (1092, 'menu.common.edit', 2137, 4, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:edit', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO `sys_menu` VALUES (1093, 'menu.common.restart', 2137, 5, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:restart', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
-- REPLACE INTO `sys_menu` VALUES (1094, 'menu.common.log', 2137, 6, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:log', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO `sys_menu` VALUES (1094, 'menu.system.setting.homeSet', 2114, 7, '', '', '1', '1', 'B', '1', '1', 'system:setting:homeSet', '#', '0', 'system', 1728641403588, 'system', 1728641403588, '');
REPLACE INTO `sys_menu` VALUES (1095, 'menu.common.start', 2137, 7, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:start', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO `sys_menu` VALUES (1096, 'menu.common.stop', 2137, 8, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:stop', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');
REPLACE INTO `sys_menu` VALUES (1097, 'menu.common.import', 2137, 9, '', '', '1', '1', 'B', '1', '1', 'ne:neInfo:import', '#', '0', 'supervisor', 1757668326671, 'supervisor', 1757668326671, '');

View File

@@ -103,6 +103,8 @@ INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1079);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1080);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1081);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1082);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1083);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1084);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1085);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1086);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1087);
@@ -112,6 +114,7 @@ INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1090);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1091);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1092);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1093);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1094);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1095);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1096);
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1097);

View File

@@ -10,6 +10,7 @@ import (
"be.ems/src/framework/reqctx"
"be.ems/src/framework/resp"
"be.ems/src/framework/utils/file"
"be.ems/src/modules/network_data/model"
"be.ems/src/modules/network_data/service"
@@ -99,3 +100,42 @@ func (s BackupController) FTPPush(c *gin.Context) {
}
c.JSON(200, resp.Ok(nil))
}
// 备份文件-导入OMC
//
// POST /import-omc
func (s BackupController) ImportOMC(c *gin.Context) {
var body struct {
NeType string `json:"neType" binding:"required,oneof=OMC"`
Path string `json:"path" binding:"required"` // 文件路径
}
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}
if !strings.HasSuffix(body.Path, ".zip") {
c.JSON(200, resp.ErrMsg("Only supports decompression of zip files"))
return
}
// 将zip文件解压到本地后复制到网元端
localFilePath := file.ParseUploadFileAbsPath(body.Path)
if err := s.backupService.BackupOMCImport(localFilePath); err != nil {
c.JSON(200, resp.ErrMsg(err.Error()))
return
}
c.JSON(200, resp.Ok(nil))
}
// 备份文件-导出OMC
//
// POST /export-omc
func (s BackupController) ExportOMC(c *gin.Context) {
zipFilePath, err := s.backupService.BackupOMCExport()
if err != nil {
c.JSON(200, resp.ErrMsg(err.Error()))
return
}
c.FileAttachment(zipFilePath, filepath.Base(zipFilePath))
}

View File

@@ -316,6 +316,16 @@ func Setup(router *gin.Engine) {
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.backup", collectlogs.BUSINESS_TYPE_OTHER)),
controller.NewBackup.FTPPush,
)
backupGroup.POST("/import-omc",
middleware.AuthorizeUser(nil),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.backup", collectlogs.BUSINESS_TYPE_IMPORT)),
controller.NewBackup.ImportOMC,
)
backupGroup.POST("/export-omc",
middleware.AuthorizeUser(nil),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.backup", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewBackup.ExportOMC,
)
}
// 网元UDM 鉴权用户信息

View File

@@ -3,11 +3,18 @@ package service
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"time"
"be.ems/src/framework/cmd"
"be.ems/src/framework/ssh"
"be.ems/src/framework/utils/file"
"be.ems/src/framework/utils/parse"
"be.ems/src/modules/network_data/model"
neModel "be.ems/src/modules/network_element/model"
neService "be.ems/src/modules/network_element/service"
systemService "be.ems/src/modules/system/service"
)
@@ -15,14 +22,12 @@ import (
// 实例化数据层 Backup 结构体
var NewBackup = &Backup{
BACKUP_DIR: "/usr/local/omc/backup",
neInfoService: neService.NewNeInfo,
sysConfigService: systemService.NewSysConfig,
}
// Backup 备份相关 服务层处理
type Backup struct {
BACKUP_DIR string // 备份目录
neInfoService *neService.NeInfo // 网元信息服务
sysConfigService *systemService.SysConfig // 参数配置服务
}
@@ -84,3 +89,194 @@ func (r Backup) FTPPushFile(localFilePath, tag string) error {
}
return nil
}
// BackupOMCImport 网元配置文件复制到网元端覆盖
func (r Backup) BackupOMCImport(localZipFile string) error {
neInfoService := neService.NewNeInfo
neVersionService := neService.NewNeVersion
neLicenseService := neService.NewNeLicense
neConfigBackupService := neService.NewNeConfigBackup
// 网管本地路径
omcPath := "/usr/local/omc/backup_omc"
if runtime.GOOS == "windows" {
omcPath = fmt.Sprintf("C:%s", omcPath)
}
// 解压到临时目录
omcPathTmp := fmt.Sprintf("%s/import", omcPath)
if err := file.UnZip(localZipFile, omcPathTmp); err != nil {
return fmt.Errorf("unzip err")
}
defer os.RemoveAll(omcPathTmp) // 删除本地临时目录
// 还原OMC-网元信息
neInfos := make([]neModel.NeInfo, 0) // 网元信息列表
neVersions := make([]neModel.NeVersion, 0) // 网元版本列表
neLicenses := make([]neModel.NeLicense, 0) // 网元许可证列表
neHosts := make([]neModel.NeHost, 0) // 网元主机列表
localDirPath := fmt.Sprintf("%s/omc/db", omcPathTmp)
neInfoStrArr := file.ReadFileJSONLine(fmt.Sprintf("%s/ne_info.json", localDirPath))
for _, str := range neInfoStrArr {
var neInfo neModel.NeInfo
if err := json.Unmarshal([]byte(str), &neInfo); err != nil {
continue
}
neInfos = append(neInfos, neInfo)
}
neVersionStrArr := file.ReadFileJSONLine(fmt.Sprintf("%s/ne_version.json", localDirPath))
for _, str := range neVersionStrArr {
var neVersion neModel.NeVersion
if err := json.Unmarshal([]byte(str), &neVersion); err != nil {
continue
}
neVersions = append(neVersions, neVersion)
}
neLicenseStrArr := file.ReadFileJSONLine(fmt.Sprintf("%s/ne_license.json", localDirPath))
for _, str := range neLicenseStrArr {
var neLicense neModel.NeLicense
if err := json.Unmarshal([]byte(str), &neLicense); err != nil {
continue
}
neLicenses = append(neLicenses, neLicense)
}
neHostStrArr := file.ReadFileJSONLine(fmt.Sprintf("%s/ne_host.json", localDirPath))
for _, str := range neHostStrArr {
var neHost neModel.NeHost
if err := json.Unmarshal([]byte(str), &neHost); err != nil {
continue
}
neHosts = append(neHosts, neHost)
}
// 新增网元信息
for _, neInfo := range neInfos {
if neInfo.NeId == "" || neInfo.NeType == "OMC" {
continue
}
// 删除网元信息
neInfoService.FindByNeTypeAndNeID(neInfo.NeType, neInfo.NeId)
if neInfo.ID > 0 {
neInfoService.DeleteByIds([]int64{neInfo.ID})
}
neVersion := neModel.NeVersion{}
for _, v := range neVersions {
if v.NeId == neInfo.NeId && v.NeType == neInfo.NeType {
v.ID = 0
neVersion = v
break
}
}
neLicense := neModel.NeLicense{}
for _, v := range neLicenses {
if v.NeId == neInfo.NeId && v.NeType == neInfo.NeType {
v.ID = 0
neLicense = v
break
}
}
neHostArr := make([]neModel.NeHost, 0) // 网元主机列表
neHostIDs := strings.Split(neInfo.HostIDs, ",")
for _, hostID := range neHostIDs {
hostIDNum := parse.Number(hostID)
for _, v := range neHosts {
if v.ID == hostIDNum {
v.ID = 0
neHostArr = append(neHostArr, v)
}
}
}
neVersionService.Insert(neVersion)
neLicenseService.Insert(neLicense)
neInfo.Hosts = neHostArr
neInfo.CreateBy = "system"
neInfoService.Insert(neInfo)
}
// 还原网元备份文件
neList := neInfoService.Find(neModel.NeInfo{}, false, false)
for _, neInfo := range neList {
if neInfo.NeType == "OMC" {
continue
}
neTypeLower := strings.ToLower(neInfo.NeType)
// 配置文件-本地复制到网元端
localDirPath := fmt.Sprintf("%s/ne_config/%s/%s", omcPathTmp, neTypeLower, neInfo.NeId)
if err := neConfigBackupService.FileLocalToNePath(neInfo, localDirPath); err != nil {
continue
}
}
return nil
}
// BackupOMCExport 备份OMC数据导出
func (r Backup) BackupOMCExport() (string, error) {
neInfoService := neService.NewNeInfo
neVersionService := neService.NewNeVersion
neLicenseService := neService.NewNeLicense
neHostService := neService.NewNeHost
neConfigBackupService := neService.NewNeConfigBackup
// 网管本地路径
omcPath := "/usr/local/omc/backup_omc"
if runtime.GOOS == "windows" {
omcPath = fmt.Sprintf("C:%s", omcPath)
}
omcPathTmp := fmt.Sprintf("%s/tmp", omcPath)
defer os.RemoveAll(omcPathTmp) // 删除本地临时目录
// 备份网元配置文件
neList := neInfoService.Find(neModel.NeInfo{}, false, false)
for _, neInfo := range neList {
if neInfo.NeType == "OMC" {
continue
}
neTypeLower := strings.ToLower(neInfo.NeType)
// 配置文件-网元端复制到本地
localDirPath := fmt.Sprintf("%s/ne_config/%s/%s", omcPathTmp, neTypeLower, neInfo.NeId)
cmd.Execf("sudo mkdir -p %s", localDirPath)
if err := neConfigBackupService.FileNeToLocalPath(neInfo, localDirPath); err != nil {
continue
}
}
// 备份OMC
neInfos := make([]any, 0) // 网元信息列表
neVersions := make([]any, 0) // 网元版本列表
neLicenses := make([]any, 0) // 网元许可证列表
neHosts := make([]any, 0) // 网元主机列表
for _, neInfo := range neList {
neVersion := neVersionService.FindByNeTypeAndNeID(neInfo.NeType, neInfo.NeId)
if neVersion.ID > 0 {
neVersions = append(neVersions, neVersion)
}
neLicense := neLicenseService.FindByNeTypeAndNeID(neInfo.NeType, neInfo.NeId)
if neLicense.ID > 0 {
neLicenses = append(neLicenses, neLicense)
}
neHostIDs := strings.Split(neInfo.HostIDs, ",")
for _, hostID := range neHostIDs {
neHost := neHostService.FindById(parse.Number(hostID))
if neHost.ID > 0 {
neHosts = append(neHosts, neHost)
}
}
neInfos = append(neInfos, neInfo)
}
localDirPath := fmt.Sprintf("%s/omc/db", omcPathTmp)
cmd.Execf("sudo mkdir -p %s", localDirPath)
file.WriterFileJSONLine(neInfos, fmt.Sprintf("%s/ne_info.json", localDirPath))
file.WriterFileJSONLine(neVersions, fmt.Sprintf("%s/ne_version.json", localDirPath))
file.WriterFileJSONLine(neLicenses, fmt.Sprintf("%s/ne_license.json", localDirPath))
file.WriterFileJSONLine(neHosts, fmt.Sprintf("%s/ne_host.json", localDirPath))
// 压缩zip文件名
zipFileName := fmt.Sprintf("BackupOMC-%s.zip", time.Now().Format("20060102150405"))
zipFilePath := fmt.Sprintf("%s/%s", omcPath, zipFileName)
if err := file.CompressZipByDir(zipFilePath, omcPathTmp); err != nil {
return "", fmt.Errorf("compress zip err")
}
return zipFilePath, nil
}

View File

@@ -79,6 +79,43 @@ func (s NeConfigBackup) FileLocalToNe(neInfo model.NeInfo, localFile string) err
return fmt.Errorf("unzip err")
}
// 本地复制到网元端
if err := s.FileLocalToNePath(neInfo, localDirPath); err != nil {
return err
}
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
return nil
}
// FileNeToLocal 网元备份文件网元端复制到本地
func (s NeConfigBackup) FileNeToLocal(neInfo model.NeInfo) (string, error) {
neTypeLower := strings.ToLower(neInfo.NeType)
// 网管本地路径
omcPath := "/usr/local/omc/backup/ne_config"
if runtime.GOOS == "windows" {
omcPath = fmt.Sprintf("C:%s", omcPath)
}
localDirPath := fmt.Sprintf("%s/%s/%s/from_ne_tmp", omcPath, neTypeLower, neInfo.NeId)
// 网元端复制到本地
if err := s.FileNeToLocalPath(neInfo, localDirPath); err != nil {
return "", err
}
// 压缩zip文件名
zipFileName := fmt.Sprintf("%s-%s-etc-%s.zip", neTypeLower, neInfo.NeId, date.ParseDateToStr(time.Now(), date.YYYYMMDDHHMMSS))
zipFilePath := fmt.Sprintf("%s/%s/%s/%s", omcPath, neTypeLower, neInfo.NeId, zipFileName)
if err := file.CompressZipByDir(zipFilePath, localDirPath); err != nil {
return "", fmt.Errorf("compress zip err")
}
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
return zipFilePath, nil
}
// FileNeToLocalPath 网元备份文件网元端复制到本地路径
func (s NeConfigBackup) FileNeToLocalPath(neInfo model.NeInfo, localDirPath string) error {
// 网元主机的SSH客户端
sshClient, err := NewNeInfo.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
if err != nil {
@@ -92,9 +129,73 @@ func (s NeConfigBackup) FileLocalToNe(neInfo model.NeInfo, localFile string) err
}
defer sftpClient.Close()
neTypeLower := strings.ToLower(neInfo.NeType)
// 网元配置文件先复制到临时目录
sshClient.RunCMD("sudo mkdir -p /tmp/omc/ne_config && sudo chmod 777 -R /tmp/omc")
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
switch neTypeLower {
case "ims":
// ims目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/ims", neDirTemp))
imsDirArr := [...]string{"bgcf", "icscf", "ismc", "mmtel", "mrf", "oam_manages.yaml", "pcscf", "scscf", "vars.cfg", "zlog"}
for _, v := range imsDirArr {
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf /usr/local/etc/ims/%s %s/ims", v, neDirTemp))
}
// mf目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/mf && sudo cp -rf /usr/local/etc/mf %s", neDirTemp, neDirTemp))
// rtproxy目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/rtproxy && sudo cp -rf /usr/local/etc/rtproxy/rtproxy.conf %s/rtproxy", neDirTemp, neDirTemp))
// iwf目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/iwf && sudo cp -rf /usr/local/etc/iwf/*.yaml %s/iwf", neDirTemp, neDirTemp))
case "udm":
// udm目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf /usr/local/etc/udm/*.yaml %s", neDirTemp, neDirTemp))
// kvdb目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/kvdb && sudo cp -rf /usr/local/etc/kvdb/*.{rdb,conf} %s/kvdb", neDirTemp, neDirTemp))
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/kvdb && sudo cp -rf /usr/local/etc/kvdb/log %s/kvdb", neDirTemp, neDirTemp))
case "smsc":
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf /usr/local/etc/smsc/{*.yaml,*.conf,*conf.txt} %s", neDirTemp, neDirTemp))
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf /usr/local/etc/smsc/conf %s/conf", neDirTemp))
default:
nePath := fmt.Sprintf("/usr/local/etc/%s/*.yaml", neTypeLower)
if neTypeLower == "amf" {
nePath = fmt.Sprintf("/usr/local/etc/%s/*.{yaml,csv}", neTypeLower)
}
if neTypeLower == "mme" {
nePath = fmt.Sprintf("/usr/local/etc/%s/*.{yaml,conf,csv}", neTypeLower)
}
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf %s %s", neDirTemp, nePath, neDirTemp))
}
// 网元端复制到本地
if err := file.CopyDir(neDirTemp, localDirPath); err != nil {
return fmt.Errorf("copy config err")
}
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
return nil
}
// FileLocalToNePath 网元备份文件本地路径复制到网元端
func (s NeConfigBackup) FileLocalToNePath(neInfo model.NeInfo, localDirPath string) error {
// 网元主机的SSH客户端
sshClient, err := NewNeInfo.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
if err != nil {
return fmt.Errorf("ne info ssh client err")
}
defer sshClient.Close()
// 网元主机的SSH客户端进行文件传输
sftpClient, err := sshClient.NewClientSFTP()
if err != nil {
return fmt.Errorf("ne info sftp client err")
}
defer sftpClient.Close()
neTypeLower := strings.ToLower(neInfo.NeType)
// 网元配置端上的临时目录
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p /tmp/omc/ne_config && sudo chmod 777 -R /tmp/omc && sudo rm -rf %s", neDirTemp))
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p %s && sudo chmod 777 -R /tmp/omc && sudo rm -rf %s", neDirTemp, neDirTemp))
// 复制到网元端
if err = sftpClient.CopyDirLocalToRemote(localDirPath, neDirTemp); err != nil {
return fmt.Errorf("copy config to ne err")
@@ -135,84 +236,6 @@ func (s NeConfigBackup) FileLocalToNe(neInfo model.NeInfo, localFile string) err
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf %s/* %s && %s", neDirTemp, neEtcPath, chmodFile))
}
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
return nil
}
// FileNeToLocal 网元备份文件网元端复制到本地
func (s NeConfigBackup) FileNeToLocal(neInfo model.NeInfo) (string, error) {
// 网元主机的SSH客户端
sshClient, err := NewNeInfo.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
if err != nil {
return "", fmt.Errorf("ne info ssh client err")
}
defer sshClient.Close()
// 网元主机的SSH客户端进行文件传输
sftpClient, err := sshClient.NewClientSFTP()
if err != nil {
return "", fmt.Errorf("ne info sftp client err")
}
defer sftpClient.Close()
neTypeLower := strings.ToLower(neInfo.NeType)
// 网管本地路径
omcPath := "/usr/local/omc/backup/ne_config"
if runtime.GOOS == "windows" {
omcPath = fmt.Sprintf("C:%s", omcPath)
}
localDirPath := fmt.Sprintf("%s/%s/%s/from_ne_tmp", omcPath, neTypeLower, neInfo.NeId)
// 网元配置文件先复制到临时目录
sshClient.RunCMD("sudo mkdir -p /tmp/omc/ne_config && sudo chmod 777 -R /tmp/omc")
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
switch neTypeLower {
case "ims":
// ims目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/ims", neDirTemp))
imsDirArr := [...]string{"bgcf", "icscf", "ismc", "mmtel", "mrf", "oam_manager.yaml", "pcscf", "scscf", "vars.cfg", "zlog"}
for _, v := range imsDirArr {
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf /usr/local/etc/ims/%s %s/ims", v, neDirTemp))
}
// mf目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/mf && sudo cp -rf /usr/local/etc/mf %s", neDirTemp, neDirTemp))
// rtproxy目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/rtproxy && sudo cp -rf /usr/local/etc/rtproxy/rtproxy.conf %s/rtproxy", neDirTemp, neDirTemp))
// iwf目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/iwf && sudo cp -rf /usr/local/etc/iwf/*.yaml %s/iwf", neDirTemp, neDirTemp))
case "udm":
// udm目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf /usr/local/etc/udm/*.yaml %s", neDirTemp, neDirTemp))
// kvdb目录
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/kvdb && sudo cp -rf /usr/local/etc/kvdb/*.{rdb,conf} %s/kvdb", neDirTemp, neDirTemp))
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/kvdb && sudo cp -rf /usr/local/etc/kvdb/log %s/kvdb", neDirTemp, neDirTemp))
case "smsc":
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf /usr/local/etc/smsc/{*.yaml,*.conf,*conf.txt} %s", neDirTemp, neDirTemp))
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf /usr/local/etc/smsc/conf %s/conf", neDirTemp))
default:
nePath := fmt.Sprintf("/usr/local/etc/%s/*.yaml", neTypeLower)
if neTypeLower == "amf" {
nePath = fmt.Sprintf("/usr/local/etc/%s/*.{yaml,csv}", neTypeLower)
}
if neTypeLower == "mme" {
nePath = fmt.Sprintf("/usr/local/etc/%s/*.{yaml,conf,csv}", neTypeLower)
}
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf %s %s", neDirTemp, nePath, neDirTemp))
}
// 网元端复制到本地
if err = sftpClient.CopyDirRemoteToLocal(neDirTemp, localDirPath); err != nil {
return "", fmt.Errorf("copy config err")
}
// 压缩zip文件名
zipFileName := fmt.Sprintf("%s-%s-etc-%s.zip", neTypeLower, neInfo.NeId, date.ParseDateToStr(time.Now(), date.YYYYMMDDHHMMSS))
zipFilePath := fmt.Sprintf("%s/%s/%s/%s", omcPath, neTypeLower, neInfo.NeId, zipFileName)
if err := file.CompressZipByDir(zipFilePath, localDirPath); err != nil {
return "", fmt.Errorf("compress zip err")
}
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
return zipFilePath, nil
}