mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-11 07:55:59 +08:00
fix: Fixed issue with recover mysql-cluster with backup files (#9707)
This commit is contained in:
parent
db8fa144eb
commit
ed288368ea
3 changed files with 11 additions and 4 deletions
|
@ -466,12 +466,12 @@ func (b *BaseApi) RecoverByUpload(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "mysql", "mariadb":
|
case "mysql", "mariadb", constant.AppMysqlCluster:
|
||||||
if err := backupService.MysqlRecoverByUpload(req); err != nil {
|
if err := backupService.MysqlRecoverByUpload(req); err != nil {
|
||||||
helper.InternalServer(c, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case constant.AppPostgresql:
|
case constant.AppPostgresql, constant.AppPostgresqlCluster:
|
||||||
if err := backupService.PostgresqlRecoverByUpload(req); err != nil {
|
if err := backupService.PostgresqlRecoverByUpload(req); err != nil {
|
||||||
helper.InternalServer(c, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -253,7 +253,12 @@ func (r *Local) Backup(info BackupInfo) error {
|
||||||
func (r *Local) Recover(info RecoverInfo) error {
|
func (r *Local) Recover(info RecoverInfo) error {
|
||||||
fi, _ := os.Open(info.SourceFile)
|
fi, _ := os.Open(info.SourceFile)
|
||||||
defer fi.Close()
|
defer fi.Close()
|
||||||
cmd := exec.Command("docker", "exec", "-i", r.ContainerName, r.Type, "-uroot", "-p"+r.Password, "--default-character-set="+info.Format, info.Name)
|
mysqlCli := r.Type
|
||||||
|
if mysqlCli == "mysql-cluster" {
|
||||||
|
mysqlCli = "mysql"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command("docker", "exec", "-i", r.ContainerName, mysqlCli, "-uroot", "-p"+r.Password, "--default-character-set="+info.Format, info.Name)
|
||||||
if strings.HasSuffix(info.SourceFile, ".gz") {
|
if strings.HasSuffix(info.SourceFile, ".gz") {
|
||||||
gzipFile, err := os.Open(info.SourceFile)
|
gzipFile, err := os.Open(info.SourceFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -271,7 +276,7 @@ func (r *Local) Recover(info RecoverInfo) error {
|
||||||
}
|
}
|
||||||
stdout, err := cmd.CombinedOutput()
|
stdout, err := cmd.CombinedOutput()
|
||||||
stdStr := strings.ReplaceAll(string(stdout), "mysql: [Warning] Using a password on the command line interface can be insecure.\n", "")
|
stdStr := strings.ReplaceAll(string(stdout), "mysql: [Warning] Using a password on the command line interface can be insecure.\n", "")
|
||||||
if err != nil || strings.HasPrefix(string(stdStr), "ERROR ") {
|
if err != nil || strings.HasPrefix(stdStr, "ERROR ") {
|
||||||
return errors.New(stdStr)
|
return errors.New(stdStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,8 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'mariadb':
|
case 'mariadb':
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
case 'mysql-cluster':
|
||||||
|
case 'postgresql-cluster':
|
||||||
title.value = name.value + ' [ ' + detailName.value + ' ]';
|
title.value = name.value + ' [ ' + detailName.value + ' ]';
|
||||||
if (detailName.value) {
|
if (detailName.value) {
|
||||||
baseDir.value = `${pathRes.data}/uploads/database/${type.value}/${name.value}/${detailName.value}/`;
|
baseDir.value = `${pathRes.data}/uploads/database/${type.value}/${name.value}/${detailName.value}/`;
|
||||||
|
|
Loading…
Add table
Reference in a new issue