[GH-ISSUE #5222] [Feature]: Implement separated (modular) backup files for Inbounds and Clients in Telegram bot notifications #3659

Open
opened 2026-10-31 20:34:02 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @solidwar on GitHub (Jun 12, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5222

Yes. While the panel already provides a full backup file, it contains all the database configurations mixed together. If an administrator only needs to migrate, review, or restore specific Inbounds or just the Clients' data, they have to deal with a large, cluttered file. It is inefficient to filter through system logs, panel settings, and core configs just to extract user or inbound data during an emergency or migration.

Describe the solution you'd like

Since the full backup is already available, I would like to propose an option to generate and send separated (modular) backup files specifically for Inbounds and Clients.

How it should work:

  1. Separated Files: Instead of one single file, the Telegram bot can send dedicated files (e.g., inbounds_backup.json and clients_backup.json).
  2. Telegram Bot Settings Toggle: In the Telegram Bot configuration section of the panel, there should be a toggle switch to enable/disable "Separated Backups". When enabled, the admin can choose to receive these specific, filtered backups.
  3. Use Case & Benefits: * Inbounds Backup: Contains only the protocols, ports, and routing configurations. Perfect for replication on a new server.
    • Clients Backup: Contains only user UUIDs, traffic limits, and expiration dates. Ideal for quickly recovering user access or syncing users across multiple backend servers without affecting the main panel settings.

Alternatives you've considered

No response

Concrete use case

No response

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

No response

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 @solidwar on GitHub (Jun 12, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5222 ### Is your feature request related to a problem? Yes. While the panel already provides a full backup file, it contains all the database configurations mixed together. If an administrator only needs to migrate, review, or restore specific Inbounds or just the Clients' data, they have to deal with a large, cluttered file. It is inefficient to filter through system logs, panel settings, and core configs just to extract user or inbound data during an emergency or migration. ### Describe the solution you'd like Since the full backup is already available, I would like to propose an option to generate and send **separated (modular) backup files** specifically for **Inbounds** and **Clients**. **How it should work:** 1. **Separated Files:** Instead of one single file, the Telegram bot can send dedicated files (e.g., `inbounds_backup.json` and `clients_backup.json`). 2. **Telegram Bot Settings Toggle:** In the Telegram Bot configuration section of the panel, there should be a toggle switch to enable/disable "Separated Backups". When enabled, the admin can choose to receive these specific, filtered backups. 3. **Use Case & Benefits:** * **Inbounds Backup:** Contains only the protocols, ports, and routing configurations. Perfect for replication on a new server. * **Clients Backup:** Contains only user UUIDs, traffic limits, and expiration dates. Ideal for quickly recovering user access or syncing users across multiple backend servers without affecting the main panel settings. ### Alternatives you've considered _No response_ ### Concrete use case _No response_ ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? _No response_ ### 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 - [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 12, 2026):

This is a valid feature request. Here is what the current implementation does and what a contribution would need to touch.

Current backup behavior (confirmed in source)

sendBackup() in internal/web/service/tgbot/tgbot_report.go (lines 398–443) sends two files:

  1. The entire SQLite database (x-ui.db) or a PostgreSQL dump (x-ui.dump), via serverService.GetDb().
  2. The full config.json generated by Xray.

This is the only backup path. There is no existing option to export inbounds or clients as separate JSON documents. The feature is triggered on-demand via the "DB Backup" inline keyboard button (tgbot_send.go:34, callback get_backup in tgbot_router.go:1130) and optionally on a schedule when the tgBotBackup setting is enabled (internal/web/service/setting.go:55).

What a PR would need to implement

  1. Data serialization — InboundService.GetAllInbounds() (defined in internal/web/service/inbound.go:341) already returns a []*model.Inbound slice including nested client stats. The inbound model (internal/database/model/) stores settings as JSON strings in columns like settings and stream_settings; encoding the slice to JSON and wrapping it in a tu.FileFromBytes document is the straightforward path. Clients can be derived from the same inbound slice (each Inbound.ClientStats contains the per-client records) or queried separately.

  2. New setting — A new boolean key (similar to tgBotBackup in internal/web/service/setting.go:55) would control whether modular backups are sent. The UI for it lives in the Telegram Bot section of the settings page (frontend/src/); a toggle there would need to persist the new key via the settings API.

  3. New tgbot functions — A sendModularBackup(chatId int64) (or two separate functions) in tgbot_report.go that serialize and send the JSON documents. A new callback case in tgbot_router.go and an optional new inline keyboard button in tgbot_send.go if on-demand triggering is desired.

  4. i18n — New message/button keys in all 13 translation files under internal/web/translation/.

  5. Scheduled send — If the modular backups should be sent automatically alongside the existing full backup, the dispatch point is internal/web/service/tgbot/tgbot_report.go:40–43.

Design note

The Inbound.Settings and Inbound.StreamSettings fields are already serialized JSON stored as strings in the database, so a round-trip export is clean. However, the exported JSON would not be directly importable via the panel's existing import flow without a matching import endpoint being added as well; that is a separate concern and out of scope for this request as written.

If you intend to open a PR, the above gives a concrete list of files to modify. The bot is in internal/web/service/tgbot/, settings service in internal/web/service/setting.go, and the data layer in internal/web/service/inbound.go.


This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4692276435 --> @github-actions[bot] commented on GitHub (Jun 12, 2026): This is a valid feature request. Here is what the current implementation does and what a contribution would need to touch. **Current backup behavior (confirmed in source)** `sendBackup()` in `internal/web/service/tgbot/tgbot_report.go` (lines 398–443) sends two files: 1. The entire SQLite database (`x-ui.db`) or a PostgreSQL dump (`x-ui.dump`), via `serverService.GetDb()`. 2. The full `config.json` generated by Xray. This is the only backup path. There is no existing option to export inbounds or clients as separate JSON documents. The feature is triggered on-demand via the "DB Backup" inline keyboard button (`tgbot_send.go:34`, callback `get_backup` in `tgbot_router.go:1130`) and optionally on a schedule when the `tgBotBackup` setting is enabled (`internal/web/service/setting.go:55`). **What a PR would need to implement** 1. **Data serialization** — `InboundService.GetAllInbounds()` (defined in `internal/web/service/inbound.go:341`) already returns a `[]*model.Inbound` slice including nested client stats. The inbound model (`internal/database/model/`) stores settings as JSON strings in columns like `settings` and `stream_settings`; encoding the slice to JSON and wrapping it in a `tu.FileFromBytes` document is the straightforward path. Clients can be derived from the same inbound slice (each `Inbound.ClientStats` contains the per-client records) or queried separately. 2. **New setting** — A new boolean key (similar to `tgBotBackup` in `internal/web/service/setting.go:55`) would control whether modular backups are sent. The UI for it lives in the Telegram Bot section of the settings page (`frontend/src/`); a toggle there would need to persist the new key via the settings API. 3. **New tgbot functions** — A `sendModularBackup(chatId int64)` (or two separate functions) in `tgbot_report.go` that serialize and send the JSON documents. A new callback case in `tgbot_router.go` and an optional new inline keyboard button in `tgbot_send.go` if on-demand triggering is desired. 4. **i18n** — New message/button keys in all 13 translation files under `internal/web/translation/`. 5. **Scheduled send** — If the modular backups should be sent automatically alongside the existing full backup, the dispatch point is `internal/web/service/tgbot/tgbot_report.go:40–43`. **Design note** The `Inbound.Settings` and `Inbound.StreamSettings` fields are already serialized JSON stored as strings in the database, so a round-trip export is clean. However, the exported JSON would not be directly importable via the panel's existing import flow without a matching import endpoint being added as well; that is a separate concern and out of scope for this request as written. If you intend to open a PR, the above gives a concrete list of files to modify. The bot is in `internal/web/service/tgbot/`, settings service in `internal/web/service/setting.go`, and the data layer in `internal/web/service/inbound.go`. --- *This reply was generated automatically; a maintainer may follow up.*
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#3659
No description provided.