|
@@ -1298,18 +1298,28 @@ func (s *ServerService) GetDb() ([]byte, error) {
|
|
|
|
|
|
|
|
// BackupFilename returns the filename for a database backup, named after the
|
|
// BackupFilename returns the filename for a database backup, named after the
|
|
|
// panel's address so a downloaded or Telegram-sent backup identifies the server
|
|
// panel's address so a downloaded or Telegram-sent backup identifies the server
|
|
|
-// it came from. requestHost is the browser's address: the getDb handler passes
|
|
|
|
|
-// c.Request.Host so a panel download is named after whatever address the user
|
|
|
|
|
-// reached the panel with, no Listen Domain needed. The Telegram bot has no
|
|
|
|
|
-// request and passes "", falling back to the configured Listen Domain (webDomain)
|
|
|
|
|
-// and then the public IP. The extension is .dump on PostgreSQL and .db on SQLite;
|
|
|
|
|
-// the base falls back to "x-ui" when no address is known.
|
|
|
|
|
|
|
+// it came from, followed by the current date and time (_YYYY-MM-DD_HHMMSS) so
|
|
|
|
|
+// files accumulated in Telegram chat history group by server then sort
|
|
|
|
|
+// chronologically and same-day backups stay distinct. requestHost is the
|
|
|
|
|
+// browser's address: the getDb handler passes c.Request.Host so a panel download
|
|
|
|
|
+// is named after whatever address the user reached the panel with, no Listen
|
|
|
|
|
+// Domain needed. The Telegram bot has no request and passes "", falling back to
|
|
|
|
|
+// the configured Listen Domain (webDomain) and then the public IP. The extension
|
|
|
|
|
+// is .dump on PostgreSQL and .db on SQLite; the base falls back to "x-ui" when
|
|
|
|
|
+// no address is known.
|
|
|
func (s *ServerService) BackupFilename(requestHost string) string {
|
|
func (s *ServerService) BackupFilename(requestHost string) string {
|
|
|
ext := ".db"
|
|
ext := ".db"
|
|
|
if database.IsPostgres() {
|
|
if database.IsPostgres() {
|
|
|
ext = ".dump"
|
|
ext = ".dump"
|
|
|
}
|
|
}
|
|
|
- return s.backupHost(requestHost) + ext
|
|
|
|
|
|
|
+ return s.backupHost(requestHost) + backupDateSuffix(time.Now()) + ext
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// backupDateSuffix returns the _YYYY-MM-DD_HHMMSS chronological suffix appended
|
|
|
|
|
+// after the host in backup filenames. Uses server-local time for consistency
|
|
|
|
|
+// with the timestamp printed in the Telegram backup message body.
|
|
|
|
|
+func backupDateSuffix(now time.Time) string {
|
|
|
|
|
+ return "_" + now.Format("2006-01-02_150405")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// backupHost picks the address used to name backup files: the browser's request
|
|
// backupHost picks the address used to name backup files: the browser's request
|