mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-28 16:01:00 +00:00
fix: Modify the service backup directory (#10930)
This commit is contained in:
@@ -286,10 +286,6 @@ func loadDbConn(snap *snapHelper, targetDir string, req dto.SnapshotCreate) erro
|
||||
func snapBaseData(snap snapHelper, targetDir string, withDockerConf bool) error {
|
||||
snap.Task.Log("---------------------- 2 / 8 ----------------------")
|
||||
snap.Task.LogStart(i18n.GetMsgByKey("SnapBaseInfo"))
|
||||
svcScriptBakPath := path.Join(targetDir, "scriptbak")
|
||||
if _, err := os.Stat(svcScriptBakPath); err != nil {
|
||||
_ = os.MkdirAll(svcScriptBakPath, os.ModePerm)
|
||||
}
|
||||
|
||||
if global.IsMaster {
|
||||
err := snap.FileOp.CopyFile("/usr/local/bin/1panel-core", targetDir)
|
||||
@@ -312,21 +308,21 @@ func snapBaseData(snap snapHelper, targetDir string, withDockerConf bool) error
|
||||
|
||||
if global.IsMaster {
|
||||
svcCorePath, _ := controller.GetServicePath("1panel-core")
|
||||
err = snap.FileOp.CopyFile(svcCorePath, svcScriptBakPath)
|
||||
err = snap.FileOp.CopyFile(svcCorePath, targetDir)
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapCopy", svcCorePath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
svcAgentName, _ := controller.GetServicePath("1panel-agent")
|
||||
err = snap.FileOp.CopyFile(svcAgentName, svcScriptBakPath)
|
||||
err = snap.FileOp.CopyFile(svcAgentName, targetDir)
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapCopy", svcAgentName), err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
initScriptPath := path.Join(global.Dir.ResourceDir, "initscript")
|
||||
if _, err := os.Stat(initScriptPath); err == nil {
|
||||
err = snap.FileOp.CopyDirWithNewName(initScriptPath, svcScriptBakPath, ".")
|
||||
err = snap.FileOp.CopyDirWithNewName(initScriptPath, targetDir, ".")
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapCopy", initScriptPath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -269,10 +269,9 @@ func backupBeforeRecover(name string, itemHelper *snapRecoverHelper) error {
|
||||
if _, err := os.Stat(baseDir); err != nil {
|
||||
_ = os.MkdirAll(baseDir, os.ModePerm)
|
||||
}
|
||||
svcScriptBakPath := path.Join(baseDir, "scriptbak")
|
||||
initScriptPath := path.Join(global.Dir.ResourceDir, "initscript")
|
||||
if _, err := os.Stat(initScriptPath); err == nil {
|
||||
err = itemHelper.FileOp.CopyDirWithNewName(initScriptPath, svcScriptBakPath, ".")
|
||||
err = itemHelper.FileOp.CopyDirWithNewName(initScriptPath, baseDir, ".")
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", initScriptPath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -313,7 +312,7 @@ func backupBeforeRecover(name string, itemHelper *snapRecoverHelper) error {
|
||||
return err
|
||||
}
|
||||
svcCorePath, _ := controller.GetServicePath("1panel-core")
|
||||
err = itemHelper.FileOp.CopyFile(svcCorePath, svcScriptBakPath)
|
||||
err = itemHelper.FileOp.CopyFile(svcCorePath, baseDir)
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", svcCorePath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -325,7 +324,7 @@ func backupBeforeRecover(name string, itemHelper *snapRecoverHelper) error {
|
||||
return err
|
||||
}
|
||||
svcAgentPath, _ := controller.GetServicePath("1panel-agent")
|
||||
err = itemHelper.FileOp.CopyFile(svcAgentPath, svcScriptBakPath)
|
||||
err = itemHelper.FileOp.CopyFile(svcAgentPath, baseDir)
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", svcAgentPath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -383,7 +382,6 @@ func recoverAppData(src string, itemHelper *snapRecoverHelper) error {
|
||||
func recoverBaseData(src string, itemHelper *snapRecoverHelper) error {
|
||||
itemHelper.Task.Log("---------------------- 6 / 11 ----------------------")
|
||||
itemHelper.Task.LogStart(i18n.GetMsgByKey("SnapBaseInfo"))
|
||||
svcScriptBakPath := path.Join(src, "scriptbak")
|
||||
if global.IsMaster {
|
||||
err := itemHelper.FileOp.CopyFile(path.Join(src, "1pctl"), "/usr/local/bin")
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", "/usr/local/bin/1pctl"), err)
|
||||
@@ -396,10 +394,10 @@ func recoverBaseData(src string, itemHelper *snapRecoverHelper) error {
|
||||
return err
|
||||
}
|
||||
svcCoreName, _ := controller.LoadServiceName("1panel-core")
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(svcScriptBakPath, svcCoreName), svcBasePath)
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, svcCoreName), svcBasePath)
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", path.Join(svcBasePath, svcCoreName)), err)
|
||||
if err != nil {
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(svcScriptBakPath, selCoreName), path.Join(svcBasePath, scriptCoreName))
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, selCoreName), path.Join(svcBasePath, scriptCoreName))
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", path.Join(svcBasePath, scriptCoreName)), err)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -412,10 +410,10 @@ func recoverBaseData(src string, itemHelper *snapRecoverHelper) error {
|
||||
return err
|
||||
}
|
||||
svcAgentName, _ := controller.LoadServiceName("1panel-agent")
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(svcScriptBakPath, svcAgentName), svcBasePath)
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, svcAgentName), svcBasePath)
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", path.Join(svcBasePath, svcAgentName)), err)
|
||||
if err != nil {
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(svcScriptBakPath, selAgentName), path.Join(svcBasePath, scriptAgentName))
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, selAgentName), path.Join(svcBasePath, scriptAgentName))
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", path.Join(svcBasePath, scriptAgentName)), err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -34,7 +34,6 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
|
||||
go func() {
|
||||
rootDir := fmt.Sprintf("%s/1panel_original/original_%s", global.Dir.BaseDir, snap.Name)
|
||||
baseDir := path.Join(rootDir, "base")
|
||||
svcScriptBakPath := path.Join(baseDir, "scriptbak")
|
||||
|
||||
FileOp := files.NewFileOp()
|
||||
taskItem.AddSubTask(
|
||||
@@ -64,7 +63,7 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
|
||||
taskItem.AddSubTask(
|
||||
i18n.GetWithName("SnapCopy", path.Join(svcBasePath, svcCoreName)),
|
||||
func(t *task.Task) error {
|
||||
return FileOp.CopyFile(path.Join(svcScriptBakPath, svcCoreName), svcBasePath)
|
||||
return FileOp.CopyFile(path.Join(baseDir, svcCoreName), svcBasePath)
|
||||
},
|
||||
nil,
|
||||
)
|
||||
@@ -72,7 +71,7 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
|
||||
taskItem.AddSubTask(
|
||||
i18n.GetWithName("SnapCopy", path.Join(svcBasePath, svcAgentName)),
|
||||
func(t *task.Task) error {
|
||||
return FileOp.CopyFile(path.Join(svcScriptBakPath, svcAgentName), svcBasePath)
|
||||
return FileOp.CopyFile(path.Join(baseDir, svcAgentName), svcBasePath)
|
||||
},
|
||||
nil,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@@ -418,7 +417,7 @@ func findModelArchive(modelType string) (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New(fmt.Sprintf("no FusionXplay_%s_Accelerator*.tar.gz found in /home/models", modelType))
|
||||
return "", fmt.Errorf("no FusionXplay_%s_Accelerator*.tar.gz found in /home/models", modelType)
|
||||
}
|
||||
|
||||
func handleModelArchive(modelType string, modelDir string) error {
|
||||
|
||||
@@ -295,10 +295,6 @@ func analyzeDoc(version, content string) dto.ReleasesNotes {
|
||||
}
|
||||
|
||||
func (u *UpgradeService) handleBackup(originalDir string) error {
|
||||
svcScriptBakPath := path.Join(originalDir, "scriptbak")
|
||||
if _, err := os.Stat(svcScriptBakPath); err != nil {
|
||||
_ = os.MkdirAll(svcScriptBakPath, os.ModePerm)
|
||||
}
|
||||
if err := files.CopyItem(false, true, "/usr/local/bin/1panel-core", originalDir); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -311,10 +307,10 @@ func (u *UpgradeService) handleBackup(originalDir string) error {
|
||||
if err := files.CopyItem(true, true, "/usr/local/bin/lang", originalDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := files.CopyItem(false, true, path.Join(svcBasePath, svcCoreName), svcScriptBakPath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(svcBasePath, svcCoreName), originalDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := files.CopyItem(false, true, path.Join(svcBasePath, svcAgentName), svcScriptBakPath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(svcBasePath, svcAgentName), originalDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := files.CopyItem(true, true, path.Join(global.CONF.Base.InstallDir, "1panel/db"), originalDir); err != nil {
|
||||
@@ -328,10 +324,6 @@ func (u *UpgradeService) handleBackup(originalDir string) error {
|
||||
|
||||
func (u *UpgradeService) handleRollback(originalDir string, errStep int) {
|
||||
_ = settingRepo.Update("SystemStatus", "Free")
|
||||
svcScriptBakPath := path.Join(originalDir, "scriptbak")
|
||||
if _, err := os.Stat(svcScriptBakPath); err != nil {
|
||||
_ = os.MkdirAll(svcScriptBakPath, os.ModePerm)
|
||||
}
|
||||
dbPath := path.Join(global.CONF.Base.InstallDir, "1panel")
|
||||
if _, err := os.Stat(path.Join(originalDir, "db")); err == nil {
|
||||
if err := files.CopyItem(true, true, path.Join(originalDir, "db"), dbPath); err != nil {
|
||||
@@ -353,10 +345,10 @@ func (u *UpgradeService) handleRollback(originalDir string, errStep int) {
|
||||
if errStep == 2 {
|
||||
return
|
||||
}
|
||||
if err := files.CopyItem(false, true, path.Join(svcScriptBakPath, svcCoreName), svcBasePath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(originalDir, svcCoreName), svcBasePath); err != nil {
|
||||
global.LOG.Errorf("rollback %s failed, err: %v", svcCoreName, err)
|
||||
}
|
||||
if err := files.CopyItem(false, true, path.Join(svcScriptBakPath, svcAgentName), svcBasePath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(originalDir, svcAgentName), svcBasePath); err != nil {
|
||||
global.LOG.Errorf("rollback %s failed, err: %v", svcAgentName, err)
|
||||
}
|
||||
if errStep == 3 {
|
||||
|
||||
@@ -79,14 +79,13 @@ var restoreCmd = &cobra.Command{
|
||||
svcAgentName, _ := controller.LoadServiceName("1panel-agent")
|
||||
selAgentName, _ := controller.SelectInitScript("1panel-agent")
|
||||
scriptAgentName, _ := controller.GetScriptName("1panel-agent")
|
||||
svcScriptBakPath := path.Join(tmpPath, "scriptbak")
|
||||
if err := files.CopyItem(false, true, path.Join(svcScriptBakPath, svcCoreName), svcBasePath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(svcScriptBakPath, selCoreName), path.Join(svcBasePath, scriptCoreName)); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(tmpPath, svcCoreName), svcBasePath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(tmpPath, selCoreName), path.Join(svcBasePath, scriptCoreName)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := files.CopyItem(false, true, path.Join(svcScriptBakPath, svcAgentName), svcBasePath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(svcScriptBakPath, selAgentName), path.Join(svcBasePath, scriptAgentName)); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(tmpPath, svcAgentName), svcBasePath); err != nil {
|
||||
if err := files.CopyItem(false, true, path.Join(tmpPath, selAgentName), path.Join(svcBasePath, scriptAgentName)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
<template>
|
||||
<DrawerPro v-model="drawerVisible" :header="$t('setting.snapshot')" @close="handleClose" size="large">
|
||||
<fu-steps
|
||||
v-loading="loading"
|
||||
class="steps"
|
||||
:space="50"
|
||||
ref="stepsRef"
|
||||
direction="vertical"
|
||||
:isLoading="stepLoading"
|
||||
:isLoading="loading"
|
||||
:finishButtonText="$t('commons.button.create')"
|
||||
@change="changeStep"
|
||||
:beforeLeave="beforeLeave"
|
||||
>
|
||||
<fu-step id="baseData" :title="$t('setting.stepBaseData')">
|
||||
<el-form
|
||||
v-loading="loading"
|
||||
class="mt-5"
|
||||
label-position="top"
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<el-form class="mt-5" label-position="top" ref="formRef" :model="form" :rules="rules">
|
||||
<el-form-item :label="$t('setting.backupAccount')" prop="fromAccounts">
|
||||
<el-select multiple @change="changeAccount(false)" v-model="form.fromAccounts" clearable>
|
||||
<div v-for="item in backupOptions" :key="item.id">
|
||||
@@ -191,7 +183,6 @@ import { ElForm } from 'element-plus';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
|
||||
const loading = ref();
|
||||
const stepLoading = ref(false);
|
||||
const stepsRef = ref();
|
||||
const nowIndex = ref(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user