1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 00:09:16 +08:00

fix: 解决计划任务备份所有应用失败的问题 (#2278)

This commit is contained in:
ssongliu 2023-09-13 17:32:12 +08:00 committed by GitHub
parent cab0c7938d
commit b9befc72a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 38 additions and 33 deletions

View File

@ -233,11 +233,11 @@ func (b *BaseApi) ListDBName(c *gin.Context) {
// @Summary Load mysql database from remote
// @Description 从服务器获取
// @Accept json
// @Param request body dto.MysqlLodaDB true "request"
// @Param request body dto.MysqlLoadDB true "request"
// @Security ApiKeyAuth
// @Router /databases/load [post]
func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
var req dto.MysqlLodaDB
var req dto.MysqlLoadDB
if err := c.ShouldBindJSON(&req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return

View File

@ -43,7 +43,7 @@ type MysqlDBCreate struct {
Description string `json:"description"`
}
type MysqlLodaDB struct {
type MysqlLoadDB struct {
From string `json:"from" validate:"required,oneof=local remote"`
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
Database string `json:"database" validate:"required"`

View File

@ -261,6 +261,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error {
upMap["hour"] = req.Hour
upMap["minute"] = req.Minute
upMap["second"] = req.Second
upMap["app_id"] = req.AppID
upMap["website"] = req.Website
upMap["exclusion_rules"] = req.ExclusionRules
upMap["db_name"] = req.DBName

View File

@ -456,7 +456,6 @@ func (u *CronjobService) handleApp(cronjob model.Cronjob, backup model.BackupAcc
if err := handleAppBackup(&app, backupDir, record.FileName); err != nil {
return paths, err
}
record.Name = app.Name
if err := backupRepo.CreateRecord(&record); err != nil {
global.LOG.Errorf("save backup record failed, err: %v", err)
return paths, err

View File

@ -35,7 +35,7 @@ type IMysqlService interface {
SearchWithPage(search dto.MysqlDBSearch) (int64, interface{}, error)
ListDBOption() ([]dto.MysqlOption, error)
Create(ctx context.Context, req dto.MysqlDBCreate) (*model.DatabaseMysql, error)
LoadFromRemote(req dto.MysqlLodaDB) error
LoadFromRemote(req dto.MysqlLoadDB) error
ChangeAccess(info dto.ChangeDBInfo) error
ChangePassword(info dto.ChangeDBInfo) error
UpdateVariables(req dto.MysqlVariablesUpdate) error
@ -144,7 +144,7 @@ func (u *MysqlService) Create(ctx context.Context, req dto.MysqlDBCreate) (*mode
return &createItem, nil
}
func (u *MysqlService) LoadFromRemote(req dto.MysqlLodaDB) error {
func (u *MysqlService) LoadFromRemote(req dto.MysqlLoadDB) error {
client, version, err := LoadMysqlClientByFrom(req.Database)
if err != nil {
return err
@ -314,7 +314,7 @@ func (u *MysqlService) ChangePassword(req dto.ChangeDBInfo) error {
return err
}
}
global.LOG.Info("excute password change sql successful")
global.LOG.Info("execute password change sql successful")
pass, err := encrypt.StringEncrypt(req.Value)
if err != nil {
return fmt.Errorf("decrypt database db password failed, err: %v", err)

View File

@ -4322,7 +4322,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.MysqlLodaDB"
"$ref": "#/definitions/dto.MysqlLoadDB"
}
}
],
@ -13690,7 +13690,7 @@ const docTemplate = `{
}
}
},
"dto.MysqlLodaDB": {
"dto.MysqlLoadDB": {
"type": "object",
"required": [
"database",

View File

@ -4315,7 +4315,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.MysqlLodaDB"
"$ref": "#/definitions/dto.MysqlLoadDB"
}
}
],
@ -13683,7 +13683,7 @@
}
}
},
"dto.MysqlLodaDB": {
"dto.MysqlLoadDB": {
"type": "object",
"required": [
"database",

View File

@ -1344,7 +1344,7 @@ definitions:
- page
- pageSize
type: object
dto.MysqlLodaDB:
dto.MysqlLoadDB:
properties:
database:
type: string
@ -6783,7 +6783,7 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/dto.MysqlLodaDB'
$ref: '#/definitions/dto.MysqlLoadDB'
responses: {}
security:
- ApiKeyAuth: []

View File

@ -82,6 +82,7 @@ export namespace Cronjob {
}
export interface Record {
id: number;
file: string;
startTime: Date;
endTime: Date;
records: string;

View File

@ -48,7 +48,7 @@ export namespace Database {
permission: string;
description: string;
}
export interface MysqlLodaDB {
export interface MysqlLoadDB {
from: string;
type: string;
database: string;

View File

@ -13,24 +13,24 @@ export const loadDatabaseFile = (type: string, database: string) => {
};
export const addMysqlDB = (params: Database.MysqlDBCreate) => {
let reqest = deepCopy(params) as Database.MysqlDBCreate;
if (reqest.password) {
reqest.password = Base64.encode(reqest.password);
let request = deepCopy(params) as Database.MysqlDBCreate;
if (request.password) {
request.password = Base64.encode(request.password);
}
return http.post(`/databases`, reqest);
return http.post(`/databases`, request);
};
export const loadDBFromRemote = (params: Database.MysqlLodaDB) => {
export const loadDBFromRemote = (params: Database.MysqlLoadDB) => {
return http.post(`/databases/load`, params);
};
export const updateMysqlAccess = (params: Database.ChangeInfo) => {
return http.post(`/databases/change/access`, params);
};
export const updateMysqlPassword = (params: Database.ChangeInfo) => {
let reqest = deepCopy(params) as Database.ChangeInfo;
if (reqest.value) {
reqest.value = Base64.encode(reqest.value);
let request = deepCopy(params) as Database.ChangeInfo;
if (request.value) {
request.value = Base64.encode(request.value);
}
return http.post(`/databases/change/password`, reqest);
return http.post(`/databases/change/password`, request);
};
export const updateMysqlDescription = (params: DescriptionUpdate) => {
return http.post(`/databases/description/update`, params);
@ -90,7 +90,7 @@ export const updateRedisConfByFile = (params: Database.RedisConfUpdateByFile) =>
return http.post(`/databases/redis/conffile/update`, params);
};
// databasae
// database
export const getDatabase = (name: string) => {
return http.get<Database.DatabaseInfo>(`/databases/db/${name}`);
};

View File

@ -587,16 +587,20 @@ const search = async () => {
};
const onDownload = async (record: any, backupID: number) => {
if (dialogData.value.rowData.dbName === 'all') {
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('database.database')]));
return;
let type = '';
switch (dialogData.value.rowData.type) {
case 'database':
type = i18n.global.t('database.database');
break;
case 'app':
type = i18n.global.t('app.app');
break;
case 'website':
type = i18n.global.t('website.website');
break;
}
if (dialogData.value.rowData.app === 'all') {
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('app.app')]));
return;
}
if (dialogData.value.rowData.website === 'all') {
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('website.website')]));
if (currentRecord.value.file.indexOf(',') !== 0) {
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [type]));
return;
}
if (!record.file || record.file.indexOf('/') === -1) {