Skip to content

feat: backup custom services on uninstall, restore on deploy#7

Merged
wangzhizhou merged 3 commits into
mainfrom
feat/service-backup-restore
Jun 16, 2026
Merged

feat: backup custom services on uninstall, restore on deploy#7
wangzhizhou merged 3 commits into
mainfrom
feat/service-backup-restore

Conversation

@wangzhizhou

Copy link
Copy Markdown
Contributor

Summary

uninstall 前将用户通过 easygate service add 添加的自定义服务 YAML 备份到 ~/.easygate.uninstall-backup/,deploy 完成后检测备份并询问用户是否恢复,避免重新安装后丢失之前添加的自定义服务。

Changes

Core logic (scripts/easygate)

  • _uninstall_backup_user_data() — 卸载前将服务 YAML + .env 备份到 $HOME/.easygate.uninstall-backup/
  • _deploy_restore_user_data() — deploy 后检测备份,交互式询问恢复,支持重载
  • deploy --no-restore — 跳过恢复询问(适合静默部署)
  • uninstall / deploy_compose / deploy_native 三处集成调用

Tests

层级 测试 场景数
静态检查 test.sh — service-helper.py Python 语法 1
单元测试 service-helper.py add/remove/list/dup/empty 9
单元测试 _deploy_restore_user_data 边界条件 7
集成测试 uninstall→deploy→restore 全流程 (compose+native) 3
E2E 测试 自定义服务路由验收 (compose + native) 2

设计要点

  • 备份位置 $HOME/.easygate.uninstall-backup/EASYGATE_HOME 之外,卸载删除后仍保留
  • 备份按需触发:只有存在实际自定义路由条目时才备份,空/纯注释 YAML 跳过
  • 恢复可跨模式:compose 备份 → native 部署仍可恢复(YAML 格式兼容)
  • CI 环境自动跳过交互(EASYGATE_CI=true

Verification

  • make test — 全部静态检查 + 行为测试通过
  • 手动测试(需要 Docker):easygate deploy --demo --local-onlyeasygate service addeasygate uninstall → 验证备份 → 重新 easygate deploy → 恢复

Co-Authored-By: Claude [email protected]

wangzhizhou and others added 3 commits June 16, 2026 12:37
uninstall 前将用户添加的自定义服务 YAML 备份到 ~/.easygate.uninstall-backup/,
deploy 完成后检测并询问用户是否恢复,避免重新安装后丢失之前添加的自定义服务。

- _uninstall_backup_user_data: 卸载前备份服务 YAML + .env
- _deploy_restore_user_data: deploy 后检测备份,交互式恢复
- deploy --no-restore 跳过恢复
- service-helper.py 单元测试 (add/remove/list/dup/empty)
- _deploy_restore_user_data 边界条件测试 (7 场景)
- 完整的 uninstall→deploy→restore 集成测试 (compose+native)
- 端到端路由验收测试 (local-acceptance + native)
- test.sh 新增 Python 语法检查

Co-Authored-By: Claude <[email protected]>
- traefik.yml already has file provider, remove duplicate cat >>
- Overwrite commented localhost-services.yml with valid YAML structure
  before service-helper.py add, so YAML parsing works correctly
- Use git checkout to restore file after test

Co-Authored-By: Claude <[email protected]>
- README: update uninstall description, add backup/restore note
- deployment.md: add --no-restore to tables, update uninstall/backup
  description, add runtime dir structure for uninstall-backup
- testing.md: update test count from 17 to 23, add new test cases,
  update route acceptance description

Co-Authored-By: Claude <[email protected]>
@wangzhizhou
wangzhizhou merged commit 740eb1b into main Jun 16, 2026
4 checks passed
@wangzhizhou
wangzhizhou deleted the feat/service-backup-restore branch June 16, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant