mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-17 03:04:46 +08:00
fix: 解决计划任务备份所有应用失败的问题 (#2278)
This commit is contained in:
parent
cab0c7938d
commit
b9befc72a3
@ -233,11 +233,11 @@ func (b *BaseApi) ListDBName(c *gin.Context) {
|
|||||||
// @Summary Load mysql database from remote
|
// @Summary Load mysql database from remote
|
||||||
// @Description 从服务器获取
|
// @Description 从服务器获取
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.MysqlLodaDB true "request"
|
// @Param request body dto.MysqlLoadDB true "request"
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Router /databases/load [post]
|
// @Router /databases/load [post]
|
||||||
func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
|
func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
|
||||||
var req dto.MysqlLodaDB
|
var req dto.MysqlLoadDB
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
|
@ -43,7 +43,7 @@ type MysqlDBCreate struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MysqlLodaDB struct {
|
type MysqlLoadDB struct {
|
||||||
From string `json:"from" validate:"required,oneof=local remote"`
|
From string `json:"from" validate:"required,oneof=local remote"`
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
|
@ -261,6 +261,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error {
|
|||||||
upMap["hour"] = req.Hour
|
upMap["hour"] = req.Hour
|
||||||
upMap["minute"] = req.Minute
|
upMap["minute"] = req.Minute
|
||||||
upMap["second"] = req.Second
|
upMap["second"] = req.Second
|
||||||
|
upMap["app_id"] = req.AppID
|
||||||
upMap["website"] = req.Website
|
upMap["website"] = req.Website
|
||||||
upMap["exclusion_rules"] = req.ExclusionRules
|
upMap["exclusion_rules"] = req.ExclusionRules
|
||||||
upMap["db_name"] = req.DBName
|
upMap["db_name"] = req.DBName
|
||||||
|
@ -456,7 +456,6 @@ func (u *CronjobService) handleApp(cronjob model.Cronjob, backup model.BackupAcc
|
|||||||
if err := handleAppBackup(&app, backupDir, record.FileName); err != nil {
|
if err := handleAppBackup(&app, backupDir, record.FileName); err != nil {
|
||||||
return paths, err
|
return paths, err
|
||||||
}
|
}
|
||||||
record.Name = app.Name
|
|
||||||
if err := backupRepo.CreateRecord(&record); err != nil {
|
if err := backupRepo.CreateRecord(&record); err != nil {
|
||||||
global.LOG.Errorf("save backup record failed, err: %v", err)
|
global.LOG.Errorf("save backup record failed, err: %v", err)
|
||||||
return paths, err
|
return paths, err
|
||||||
|
@ -35,7 +35,7 @@ type IMysqlService interface {
|
|||||||
SearchWithPage(search dto.MysqlDBSearch) (int64, interface{}, error)
|
SearchWithPage(search dto.MysqlDBSearch) (int64, interface{}, error)
|
||||||
ListDBOption() ([]dto.MysqlOption, error)
|
ListDBOption() ([]dto.MysqlOption, error)
|
||||||
Create(ctx context.Context, req dto.MysqlDBCreate) (*model.DatabaseMysql, 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
|
ChangeAccess(info dto.ChangeDBInfo) error
|
||||||
ChangePassword(info dto.ChangeDBInfo) error
|
ChangePassword(info dto.ChangeDBInfo) error
|
||||||
UpdateVariables(req dto.MysqlVariablesUpdate) error
|
UpdateVariables(req dto.MysqlVariablesUpdate) error
|
||||||
@ -144,7 +144,7 @@ func (u *MysqlService) Create(ctx context.Context, req dto.MysqlDBCreate) (*mode
|
|||||||
return &createItem, nil
|
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)
|
client, version, err := LoadMysqlClientByFrom(req.Database)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -314,7 +314,7 @@ func (u *MysqlService) ChangePassword(req dto.ChangeDBInfo) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global.LOG.Info("excute password change sql successful")
|
global.LOG.Info("execute password change sql successful")
|
||||||
pass, err := encrypt.StringEncrypt(req.Value)
|
pass, err := encrypt.StringEncrypt(req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("decrypt database db password failed, err: %v", err)
|
return fmt.Errorf("decrypt database db password failed, err: %v", err)
|
||||||
|
@ -4322,7 +4322,7 @@ const docTemplate = `{
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/dto.MysqlLodaDB"
|
"$ref": "#/definitions/dto.MysqlLoadDB"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -13690,7 +13690,7 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dto.MysqlLodaDB": {
|
"dto.MysqlLoadDB": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"database",
|
"database",
|
||||||
|
@ -4315,7 +4315,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/dto.MysqlLodaDB"
|
"$ref": "#/definitions/dto.MysqlLoadDB"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -13683,7 +13683,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dto.MysqlLodaDB": {
|
"dto.MysqlLoadDB": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"database",
|
"database",
|
||||||
|
@ -1344,7 +1344,7 @@ definitions:
|
|||||||
- page
|
- page
|
||||||
- pageSize
|
- pageSize
|
||||||
type: object
|
type: object
|
||||||
dto.MysqlLodaDB:
|
dto.MysqlLoadDB:
|
||||||
properties:
|
properties:
|
||||||
database:
|
database:
|
||||||
type: string
|
type: string
|
||||||
@ -6783,7 +6783,7 @@ paths:
|
|||||||
name: request
|
name: request
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/dto.MysqlLodaDB'
|
$ref: '#/definitions/dto.MysqlLoadDB'
|
||||||
responses: {}
|
responses: {}
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
|
@ -82,6 +82,7 @@ export namespace Cronjob {
|
|||||||
}
|
}
|
||||||
export interface Record {
|
export interface Record {
|
||||||
id: number;
|
id: number;
|
||||||
|
file: string;
|
||||||
startTime: Date;
|
startTime: Date;
|
||||||
endTime: Date;
|
endTime: Date;
|
||||||
records: string;
|
records: string;
|
||||||
|
@ -48,7 +48,7 @@ export namespace Database {
|
|||||||
permission: string;
|
permission: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
export interface MysqlLodaDB {
|
export interface MysqlLoadDB {
|
||||||
from: string;
|
from: string;
|
||||||
type: string;
|
type: string;
|
||||||
database: string;
|
database: string;
|
||||||
|
@ -13,24 +13,24 @@ export const loadDatabaseFile = (type: string, database: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const addMysqlDB = (params: Database.MysqlDBCreate) => {
|
export const addMysqlDB = (params: Database.MysqlDBCreate) => {
|
||||||
let reqest = deepCopy(params) as Database.MysqlDBCreate;
|
let request = deepCopy(params) as Database.MysqlDBCreate;
|
||||||
if (reqest.password) {
|
if (request.password) {
|
||||||
reqest.password = Base64.encode(reqest.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);
|
return http.post(`/databases/load`, params);
|
||||||
};
|
};
|
||||||
export const updateMysqlAccess = (params: Database.ChangeInfo) => {
|
export const updateMysqlAccess = (params: Database.ChangeInfo) => {
|
||||||
return http.post(`/databases/change/access`, params);
|
return http.post(`/databases/change/access`, params);
|
||||||
};
|
};
|
||||||
export const updateMysqlPassword = (params: Database.ChangeInfo) => {
|
export const updateMysqlPassword = (params: Database.ChangeInfo) => {
|
||||||
let reqest = deepCopy(params) as Database.ChangeInfo;
|
let request = deepCopy(params) as Database.ChangeInfo;
|
||||||
if (reqest.value) {
|
if (request.value) {
|
||||||
reqest.value = Base64.encode(reqest.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) => {
|
export const updateMysqlDescription = (params: DescriptionUpdate) => {
|
||||||
return http.post(`/databases/description/update`, params);
|
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);
|
return http.post(`/databases/redis/conffile/update`, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
// databasae
|
// database
|
||||||
export const getDatabase = (name: string) => {
|
export const getDatabase = (name: string) => {
|
||||||
return http.get<Database.DatabaseInfo>(`/databases/db/${name}`);
|
return http.get<Database.DatabaseInfo>(`/databases/db/${name}`);
|
||||||
};
|
};
|
||||||
|
@ -587,16 +587,20 @@ const search = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onDownload = async (record: any, backupID: number) => {
|
const onDownload = async (record: any, backupID: number) => {
|
||||||
if (dialogData.value.rowData.dbName === 'all') {
|
let type = '';
|
||||||
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('database.database')]));
|
switch (dialogData.value.rowData.type) {
|
||||||
return;
|
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') {
|
if (currentRecord.value.file.indexOf(',') !== 0) {
|
||||||
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('app.app')]));
|
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [type]));
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (dialogData.value.rowData.website === 'all') {
|
|
||||||
MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('website.website')]));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!record.file || record.file.indexOf('/') === -1) {
|
if (!record.file || record.file.indexOf('/') === -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user