数据迁移
由于DevKit 25.3.0版本变更较大,无法直接从旧版本升级,需手动迁移历史数据至新版本。
- 在安装25.3.0版本之前,请先备份当前DevKit的数据。以原安装路径为“/opt”,备份路径为“/opt/DevKitBack”为例。
mkdir -p /opt/DevKitBack cp -r /opt/DevKit /opt/DevKitBack
- 备份完成后卸载DevKit。
bash /opt/DevKit/tools/uninstall.sh
- 安装新版本DevKit(即25.3.0),详见安装。以安装用户为test1,安装目录为“/opt”为例。
test1需要对“/opt”路径有读写执行权限,请使用root用户执行以下命令。
setfacl -m u:test1:rwx /opt
为确保历史报告能够正常查看,建议安装目录与升级前保持一致,否则可能会因路径变更导致无法找到源文件。
- 安装完成后,请使用root用户调用以下脚本完成数据迁移。
- 新建脚本。
vi data_migration.sh
- 按“i”进入编辑模式,添加以下内容。
#!/bin/bash install_path="$1" old_install_path="$2" group_name1="$3" user_name1="$4" function main() { # 数据库拷贝 del_frame_sqlite3 del_devkitplugins_sqlite3 # 拷贝日志 DevKit/logs move_logs # 拷贝报告 DevKit/workspace move_workspace_report # 性能组 远程节点信息拷贝 move_node_ssh # 删除矩阵化clang_include目录(全量升级亲和时文件会重复) if [ -d "${install_path}/DevKit/tools/clang_include" ] && [[ "${install_path}" ]]; then rm -rf "${install_path}/DevKit/tools/clang_include" fi # 修改权限 root改成安装用户属组---- chown -R "${group_name1}":"${user_name1}" "${install_path}/DevKit/" echo_and_log "DevKit data is migrate successfully." "${SUCCESS}" } function del_frame_sqlite3() { local bak_frame_sql="${old_install_path}/DevKit/devkitframework/db.sqlite3" cp -rfp "${bak_frame_sql}" "${install_path}/DevKit/devkitframework/" if [ "0" != "$?" ]; then echo_and_log "Failed to restore framework sqlite3 file." "${ERROR}" exit 1 fi } function del_devkitplugins_sqlite3() { local bak_plugin_sql="${old_install_path}/DevKit/devkitplugins/sqlite/db.sqlite3" cp -rfp "${bak_plugin_sql}" "${install_path}/DevKit/devkitplugins/sqlite/" if [ "0" != "$?" ]; then echo_and_log "Failed to restore plugins sqlite3 file." "${ERROR}" exit 1 fi } function move_workspace_report() { local move_workspace_report="${old_install_path}/DevKit/workspace/" cp -rfp "${move_workspace_report}" "${install_path}/DevKit/" if [ "0" != "$?" ]; then echo_and_log "Failed to restore workspace file." "${ERROR}" fi } function move_logs() { local move_workspace_report="${old_install_path}/DevKit/logs/" cp -rfp "${move_workspace_report}" "${install_path}/DevKit/" if [ "0" != "$?" ]; then echo_and_log "Failed to restore Logs file." "${ERROR}" fi } # 迁移节点免密数据到新目录 function move_node_ssh() { local old_node_ssh="${install_path}/DevKit/workspace/devadmin/ssh/sys_perf/install_node/" local new_node_ssh="${install_path}/DevKit/config/agent_space/ssh/sys_perf/" # 检查目标路径是否存在,不存在则退出函数 if [ ! -e "${old_node_ssh}" ]; then return # 退出当前函数 fi cp -rpf "${old_node_ssh}" "${new_node_ssh}" if [ $? == 0 ]; then echo_and_log "Successfully move node ssh files" "${SUCCESS}" else echo_and_log "Failed to copy node ssh files" "${ERROR}" # 可选的错误提示 fi } # 终端及日志打印:echo_and_log [info] [status] [log] function echo_and_log() { local info=$1 local status=$2 local log="" local type="32" if [ $# == 3 ]; then log=$3 # 选填 if [ -L "${log}" ]; then echo -e "\e[1;31m The soft link file ${log} is detected. Exit the current operation.\e[0m" exit "${ERROR}" fi if [ ! -f "${log}" ]; then echo -e "\e[1;31m echo_and_log:${log} is not exist \e[0m" exit "${ERROR}" fi fi case "${status}" in 0) type="32";; # 绿色 1) type="31";; # 红色 2) type="33";; # 黄色 3) type="37";; # 白色 *) esac if [ -z "${log}" ]; then echo -e "\e[1;${type}m ${info} \e[0m" else if [ ! -f "${log}" ]; then echo -e "\e[1;31m echo_and_log:${log} is not exist \e[0m" exit "${ERROR}" fi echo -e "\e[1;${type}m ${info} \e[0m" | tee -a "${log}" fi } main - 按“Esc”,输入:wq!,按“Enter”保存并退出。
- 执行脚本迁移数据。
bash data_migration.sh /opt /opt/DevKitBack test1 test1
若返回以下信息则表示迁移成功。
DevKit data is migrate successfully.
- /opt:表示新版本DevKit安装目录。
- /opt/DevKitBack:表示旧版本DevKit备份目录,请勿以斜杠 (/) 结尾。
- test1 test1:表示安装新版本DevKit时使用用户的用户组和用户名。
- 新建脚本。
- 登录DevKit确认历史报告是否可正常查看。若无问题,则表示数据迁移成功,可移除之前的备份文件。
rm -rf /opt/DevKitBack
父主题: 常用操作