mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
Update DB WAL before backup
This commit is contained in:
@@ -418,6 +418,11 @@ func (s *ServerService) GetConfigJson() (interface{}, error) {
|
||||
}
|
||||
|
||||
func (s *ServerService) GetDb() ([]byte, error) {
|
||||
// Update by manually trigger a checkpoint operation
|
||||
err := database.Checkpoint()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Open the file for reading
|
||||
file, err := os.Open(config.GetDBPath())
|
||||
if err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
"x-ui/config"
|
||||
"x-ui/database"
|
||||
"x-ui/database/model"
|
||||
"x-ui/logger"
|
||||
"x-ui/util/common"
|
||||
@@ -697,12 +698,18 @@ func (t *Tgbot) sendBackup(chatId int64) {
|
||||
return
|
||||
}
|
||||
|
||||
// Update by manually trigger a checkpoint operation
|
||||
err := database.Checkpoint()
|
||||
if err != nil {
|
||||
logger.Warning("Error in trigger a checkpoint operation: ", err)
|
||||
}
|
||||
|
||||
output := t.I18nBot("tgbot.messages.backupTime", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
||||
t.SendMsgToTgbot(chatId, output)
|
||||
|
||||
file := tgbotapi.FilePath(config.GetDBPath())
|
||||
msg := tgbotapi.NewDocument(chatId, file)
|
||||
_, err := bot.Send(msg)
|
||||
_, err = bot.Send(msg)
|
||||
if err != nil {
|
||||
logger.Warning("Error in uploading backup: ", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user