[PR #5606] [MERGED] feat(backup): prefix backup filenames with date and time #5924

Closed
opened 2026-11-02 04:05:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5606
Author: @NikanZeyaei
Created: 6/27/2026
Status: ✅ Merged
Merged: 6/27/2026
Merged by: @MHSanaei

Base: main ← Head: feature/backup-date-prefix


📝 Commits (3)

  • 7ad0876 feat(backup): add YYYY-MM-DD_ date prefix to backup filenames
  • 546cb11 feat(backup): prefix backup filenames with date and time
  • 380c75c fix(backup): put host before date in backup filename

📊 Changes

2 files changed (+47 additions, -7 deletions)

View changed files

📝 internal/web/service/backup_filename_test.go (+30 -0)
📝 internal/web/service/server.go (+17 -7)

📄 Description

Summary

Prepends a YYYY-MM-DD_ date prefix to database backup filenames (e.g. 2026-06-27_panel.example.com.db) so backups accumulated in Telegram chat history or downloads are chronologically sortable and distinguishable without opening them.

Why

Backups sent via Telegram DM and panel downloads share identical filenames (<domain>.db), making a fresh backup indistinguishable from an old one without downloading. The date prefix lets admins sort and identify backups at a glance.

Refs #5584

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • New unit test TestBackupDatePrefix in internal/web/service/backup_filename_test.go verifies the prefix format (^\d{4}-\d{2}-\d{2}_$) against fixed time.Time inputs (UTC midnight, year-end, single-digit month/day padding) and asserts it satisfies the controller's ^[a-zA-Z0-9_\-.]+$ filename safety regex.
  • Existing TestSanitizeBackupHost still passes.
  • go vet ./internal/web/service/... clean.
  • go build ./... succeeds.
  • go test -run 'TestBackup|TestSanitizeBackupHost' -count=1 ./internal/web/service/... → 13 passed.
  • Manual: reviewer can trigger a Telegram backup (/backup or equivalent bot command) and confirm the received file is named 2026-06-27_<host>.db (.dump on PostgreSQL).

Screenshots / recordings

N/A — no UI changes.

Breaking changes

None. No restore/import path reads the filename (restore uses uploaded bytes), so prefixing is non-breaking. Existing backup files on disk are unaffected.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5606 **Author:** [@NikanZeyaei](https://github.com/NikanZeyaei) **Created:** 6/27/2026 **Status:** ✅ Merged **Merged:** 6/27/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feature/backup-date-prefix` --- ### 📝 Commits (3) - [`7ad0876`](https://github.com/MHSanaei/3x-ui/commit/7ad087639b6a3ad89131f5f7593138f8c03db36b) feat(backup): add YYYY-MM-DD_ date prefix to backup filenames - [`546cb11`](https://github.com/MHSanaei/3x-ui/commit/546cb11e271485cc05b463949816aaaf9d259de3) feat(backup): prefix backup filenames with date and time - [`380c75c`](https://github.com/MHSanaei/3x-ui/commit/380c75cc12023fa7426f237674557d349e16dc3d) fix(backup): put host before date in backup filename ### 📊 Changes **2 files changed** (+47 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/backup_filename_test.go` (+30 -0) 📝 `internal/web/service/server.go` (+17 -7) </details> ### 📄 Description ## Summary Prepends a `YYYY-MM-DD_` date prefix to database backup filenames (e.g. `2026-06-27_panel.example.com.db`) so backups accumulated in Telegram chat history or downloads are chronologically sortable and distinguishable without opening them. ## Why Backups sent via Telegram DM and panel downloads share identical filenames (`<domain>.db`), making a fresh backup indistinguishable from an old one without downloading. The date prefix lets admins sort and identify backups at a glance. Refs #5584 ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [x] Telegram bot ## How was this tested? - New unit test `TestBackupDatePrefix` in `internal/web/service/backup_filename_test.go` verifies the prefix format (`^\d{4}-\d{2}-\d{2}_$`) against fixed `time.Time` inputs (UTC midnight, year-end, single-digit month/day padding) and asserts it satisfies the controller's `^[a-zA-Z0-9_\-.]+$` filename safety regex. - Existing `TestSanitizeBackupHost` still passes. - `go vet ./internal/web/service/...` clean. - `go build ./...` succeeds. - `go test -run 'TestBackup|TestSanitizeBackupHost' -count=1 ./internal/web/service/...` → 13 passed. - Manual: reviewer can trigger a Telegram backup (`/backup` or equivalent bot command) and confirm the received file is named `2026-06-27_<host>.db` (`.dump` on PostgreSQL). ## Screenshots / recordings N/A — no UI changes. ## Breaking changes None. No restore/import path reads the filename (restore uses uploaded bytes), so prefixing is non-breaking. Existing backup files on disk are unaffected. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:03 +07:00
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#5924
No description provided.