[GH-ISSUE #5004] [Feature]: Add toggles for not exporting host-specific options #3520

Closed
opened 2026-10-31 20:33:02 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Michael-YS on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5004

The db export right now would also export machine specific configs such as cert details, which makes transferring to another host almost impossible.

Describe the solution you'd like

In the export page, add options to not include ssl configurations

Alternatives you've considered

I tried manually edit the exported db files to remove those ssl lines. However, after uploading it to the panel, it overwrites the existing ssl configs.

Concrete use case

Say I have 2 machines, with 3x-ui installed on machine A. Now I want to install the same config on machine B. I export the db from Machine A and import it to Machine B. And now the panel broke due to ssl config errors.

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

Other

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @Michael-YS on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5004 ### Is your feature request related to a problem? The db export right now would also export machine specific configs such as cert details, which makes transferring to another host almost impossible. ### Describe the solution you'd like In the export page, add options to not include ssl configurations ### Alternatives you've considered I tried manually edit the exported db files to remove those ssl lines. However, after uploading it to the panel, it overwrites the existing ssl configs. ### Concrete use case Say I have 2 machines, with 3x-ui installed on machine A. Now I want to install the same config on machine B. I export the db from Machine A and import it to Machine B. And now the panel broke due to ssl config errors. ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? Other ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 6, 2026):

Thanks for the well-described report — this is a valid and reproducible issue with the current export/import flow.

What's happening under the hood

GET /panel/api/server/getDb (the "Export Database" button in BackupModal.tsx) sends the entire raw SQLite file byte-for-byte. All panel settings are stored as key-value rows in a single settings table, so there's no filtering — everything is exported together: inbounds, clients, users, and host-specific panel settings.

POST /panel/api/server/importDB then replaces the entire database (web/service/server.go ~L1300), overwriting every setting on the destination machine, including its own cert paths, ports, and base path.

Which settings are host-specific

The keys that typically differ between machines (defined in web/service/setting.go):

Setting key What it holds
webCertFile / webKeyFile Panel TLS certificate/key file paths
subCertFile / subKeyFile Subscription server TLS cert/key paths
webPort / webListen / webDomain Panel network binding
webBasePath Panel URL base path
subPort / subListen / subDomain / subPath Subscription server binding
secret Session signing secret
apiToken Panel API token

After an import these are all overwritten with the values from machine A, so if machine B doesn't have certs at the same file paths (or uses a different port/base path) the panel will fail to start TLS.

Possible implementation approaches

  1. "Export without settings" endpoint — a new backend route that dumps only the inbounds, client_traffics, users, and related tables (not settings), and a matching import that merges only those tables while leaving settings untouched on the destination. This is the cleanest solution because it clearly separates inbound configuration from host configuration.

  2. Selective import — on import, copy the uploaded DB but then restore a list of known host-specific keys from the destination's current DB before swapping. Simpler to implement but requires maintaining a hardcoded allowlist of keys to preserve.

  3. Export with UI toggles (as requested) — add checkboxes in BackupModal.tsx to include/exclude the settings table or specific key groups. This requires a parameterized export endpoint and a non-raw export format (e.g. JSON or a filtered SQL dump), since the current raw-file approach can't omit individual table rows.

Approach 1 or 2 are probably the most practical starting points. If you or someone wants to implement this, the main files to touch are:

  • web/service/server.go — GetDb / ImportDB (or new variants)
  • web/controller/server.go — add/modify routes
  • frontend/src/pages/index/BackupModal.tsx — add the UI controls
<!-- gh-comment-id:4638238534 --> @github-actions[bot] commented on GitHub (Jun 6, 2026): Thanks for the well-described report — this is a valid and reproducible issue with the current export/import flow. ## What's happening under the hood `GET /panel/api/server/getDb` (the "Export Database" button in `BackupModal.tsx`) sends the **entire raw SQLite file** byte-for-byte. All panel settings are stored as key-value rows in a single `settings` table, so there's no filtering — everything is exported together: inbounds, clients, users, *and* host-specific panel settings. `POST /panel/api/server/importDB` then **replaces the entire database** (`web/service/server.go` ~L1300), overwriting every setting on the destination machine, including its own cert paths, ports, and base path. ## Which settings are host-specific The keys that typically differ between machines (defined in `web/service/setting.go`): | Setting key | What it holds | |---|---| | `webCertFile` / `webKeyFile` | Panel TLS certificate/key file paths | | `subCertFile` / `subKeyFile` | Subscription server TLS cert/key paths | | `webPort` / `webListen` / `webDomain` | Panel network binding | | `webBasePath` | Panel URL base path | | `subPort` / `subListen` / `subDomain` / `subPath` | Subscription server binding | | `secret` | Session signing secret | | `apiToken` | Panel API token | After an import these are all overwritten with the values from machine A, so if machine B doesn't have certs at the same file paths (or uses a different port/base path) the panel will fail to start TLS. ## Possible implementation approaches 1. **"Export without settings" endpoint** — a new backend route that dumps only the `inbounds`, `client_traffics`, `users`, and related tables (not `settings`), and a matching import that merges only those tables while leaving `settings` untouched on the destination. This is the cleanest solution because it clearly separates *inbound configuration* from *host configuration*. 2. **Selective import** — on import, copy the uploaded DB but then restore a list of known host-specific keys from the destination's current DB before swapping. Simpler to implement but requires maintaining a hardcoded allowlist of keys to preserve. 3. **Export with UI toggles** (as requested) — add checkboxes in `BackupModal.tsx` to include/exclude the `settings` table or specific key groups. This requires a parameterized export endpoint and a non-raw export format (e.g. JSON or a filtered SQL dump), since the current raw-file approach can't omit individual table rows. Approach 1 or 2 are probably the most practical starting points. If you or someone wants to implement this, the main files to touch are: - `web/service/server.go` — `GetDb` / `ImportDB` (or new variants) - `web/controller/server.go` — add/modify routes - `frontend/src/pages/index/BackupModal.tsx` — add the UI controls
Author
Owner

@AndreyKaller commented on GitHub (Jun 6, 2026):

Indeed, I agree with the author. Migrating is completely pointless without a complete reinstallation of 3x-ui. Because the old server settings (the path to the subscriptions, the subscription links themselves, the ports) simply don't work on the new hardware. And you have to reissue keys. Even if you manually enter everything and replicate the old paths on the new host, subscriptions will still return an error and won't be able to update. Because these paths don't create new user settings. I think a complete, turnkey migration function needs to be developed!

<!-- gh-comment-id:4638280068 --> @AndreyKaller commented on GitHub (Jun 6, 2026): Indeed, I agree with the author. Migrating is completely pointless without a complete reinstallation of 3x-ui. Because the old server settings (the path to the subscriptions, the subscription links themselves, the ports) simply don't work on the new hardware. And you have to reissue keys. Even if you manually enter everything and replicate the old paths on the new host, subscriptions will still return an error and won't be able to update. Because these paths don't create new user settings. I think a complete, turnkey migration function needs to be developed!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3520
No description provided.