mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-17 02:46:49 +08:00
fix: Fix snapshot restoration for container configuration errors (#9277)
Refs #9216
This commit is contained in:
parent
249b3c3245
commit
984985e650
3 changed files with 10 additions and 10 deletions
|
@ -321,9 +321,9 @@ func snapBaseData(snap snapHelper, targetDir string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if snap.FileOp.Stat("/etc/docker/daemon.json") {
|
||||
err = snap.FileOp.CopyFile("/etc/docker/daemon.json", targetDir)
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapCopy", "/etc/docker/daemon.json"), err)
|
||||
if snap.FileOp.Stat(constant.DaemonJsonPath) {
|
||||
err = snap.FileOp.CopyFile(constant.DaemonJsonPath, targetDir)
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapCopy", constant.DaemonJsonPath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -285,9 +285,9 @@ func backupBeforeRecover(name string, itemHelper *snapRecoverHelper) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if itemHelper.FileOp.Stat("/etc/docker/daemon.json") {
|
||||
err = itemHelper.FileOp.CopyFile("/etc/docker/daemon.json", baseDir)
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", "/etc/docker/daemon.json"), err)
|
||||
if itemHelper.FileOp.Stat(constant.DaemonJsonPath) {
|
||||
err = itemHelper.FileOp.CopyFile(constant.DaemonJsonPath, baseDir)
|
||||
itemHelper.Task.LogWithStatus(i18n.GetWithName("SnapCopy", constant.DaemonJsonPath), err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -368,15 +368,15 @@ func recoverBaseData(src string, itemHelper *snapRecoverHelper) error {
|
|||
return err
|
||||
}
|
||||
|
||||
daemonJsonPath := "/etc/docker/daemon.json"
|
||||
_, errSrc := os.Stat(path.Join(src, "docker/daemon.json"))
|
||||
daemonJsonPath := constant.DaemonJsonPath
|
||||
_, errSrc := os.Stat(path.Join(src, "daemon.json"))
|
||||
_, errPath := os.Stat(daemonJsonPath)
|
||||
if os.IsNotExist(errSrc) && os.IsNotExist(errPath) {
|
||||
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverDaemonJsonEmpty"))
|
||||
return nil
|
||||
}
|
||||
if errSrc == nil {
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, "docker/daemon.json"), "/etc/docker")
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, "daemon.json"), "/etc/docker")
|
||||
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverDaemonJson"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("recover docker daemon.json failed, err: %v", err)
|
||||
|
|
|
@ -76,7 +76,7 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
|
|||
nil,
|
||||
)
|
||||
taskItem.AddSubTask(
|
||||
i18n.GetWithName("SnapCopy", "/etc/docker/daemon.json"),
|
||||
i18n.GetWithName("SnapCopy", constant.DaemonJsonPath),
|
||||
func(t *task.Task) error {
|
||||
return FileOp.CopyFile(path.Join(baseDir, "daemon.json"), "/etc/docker")
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue