fix: 修复备份工具的多处问题
- go.mod: 将非法版本号 go 1.26.4 改为 go 1.26 - engine: 压缩失败时删除残留的半截 tar.gz 文件 - config: 支持仅按天数保留(count 和 days 均未设时才用默认 count=7) - engine: docker compose stop 失败时也尝试重启,避免容器停摆 - list: 仅显示真正的备份归档文件(新增导出 IsBackupArchive) - systemd: 移除 PrivateTmp,暂存目录改到安装目录内,避免私有 /tmp 被大目录撑爆
This commit is contained in:
@@ -83,9 +83,12 @@ func (e *Engine) backupOne(ctx context.Context, proj config.ProjectConfig) Resul
|
||||
|
||||
executor := NewComposeExecutor(proj.Path, proj.ComposeFile)
|
||||
|
||||
// 1. Stop the compose project.
|
||||
// 1. Stop the compose project. If the stop is interrupted midway
|
||||
// (e.g. the context is cancelled), containers may be left stopped, so
|
||||
// always attempt a restart before returning.
|
||||
stopStart := time.Now()
|
||||
if err := executor.Stop(ctx); err != nil {
|
||||
_ = restartCompose(executor)
|
||||
result.Error = fmt.Errorf("stop: %w", err)
|
||||
result.Duration = time.Since(start)
|
||||
return result
|
||||
@@ -226,9 +229,14 @@ func createTarGz(ctx context.Context, srcDir, dstPath string) error {
|
||||
|
||||
closeErr := closeTarGz(tw, gw, f)
|
||||
if walkErr != nil {
|
||||
_ = os.Remove(dstPath)
|
||||
return walkErr
|
||||
}
|
||||
return closeErr
|
||||
if closeErr != nil {
|
||||
_ = os.Remove(dstPath)
|
||||
return closeErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func closeTarGz(tw *tar.Writer, gw *gzip.Writer, f *os.File) error {
|
||||
|
||||
Reference in New Issue
Block a user