Skip to content

Commit dff3844

Browse files
committed
fix: make backup archives collision-safe
1 parent 7057b18 commit dff3844

5 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎next/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
- Agent Event/Completion Outbox 在磁盘写入失败时不再提前提交内存变更,避免事件序号跳跃或误删未确认 Completion。
2424
- Linux、macOS、Windows 卸载脚本遵循自定义安装/配置/数据目录;默认保留数据,只有显式 Purge 才删除。
25+
- Linux、macOS、Windows 连续备份使用唯一归档名,避免同一秒内自动升级和人工备份发生文件名碰撞。
2526

2627
## 0.1.0-beta.1 — 2026-08-28
2728

‎next/distribution/src/main/distribution/install/linux/backup.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ restore_services() {
2828
if [ "$AGENT_ACTIVE" = true ]; then systemctl start wepush-next-agent.service; fi
2929
}
3030
TEMP=$(mktemp -d "${TMPDIR:-/tmp}/wepush-next-backup.XXXXXX")
31+
BACKUP_ID=${TEMP##*.}
3132
cleanup() { rm -rf "$TEMP"; restore_services; }
3233
trap cleanup EXIT HUP INT TERM
3334
install -d -m 0700 "$TEMP/payload/config" "$TEMP/payload/data"
@@ -43,7 +44,7 @@ createdAt=$STAMP
4344
contents=config,database,master-key,artifacts,agent-identity,journal,outbox,plugins
4445
EOF
4546
(cd "$TEMP" && find payload -type f -print | LC_ALL=C sort | while IFS= read -r FILE; do sha256sum "$FILE"; done > SHA256SUMS)
46-
ARCHIVE="$DESTINATION/wepush-next-$STAMP.tar.gz"
47+
ARCHIVE="$DESTINATION/wepush-next-$STAMP-$BACKUP_ID.tar.gz"
4748
tar -C "$TEMP" -czf "$ARCHIVE" BACKUP-MANIFEST SHA256SUMS payload
4849
chmod 0600 "$ARCHIVE"
4950
"$(dirname -- "$0")/restore.sh" --validate-only "$ARCHIVE"

‎next/distribution/src/main/distribution/install/macos/backup.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ restore_services() {
3232
if [ "$AGENT_ACTIVE" = true ]; then launchctl bootstrap system /Library/LaunchDaemons/com.fangxuele.wepush-next.agent.plist; fi
3333
}
3434
TEMP=$(mktemp -d "${TMPDIR:-/tmp}/wepush-next-backup.XXXXXX")
35+
BACKUP_ID=${TEMP##*.}
3536
cleanup() { rm -rf "$TEMP"; restore_services; }
3637
trap cleanup EXIT HUP INT TERM
3738
install -d -m 0700 "$TEMP/payload/config" "$TEMP/payload/data"
@@ -47,7 +48,7 @@ createdAt=$STAMP
4748
contents=config,database,master-key,artifacts,agent-identity,journal,outbox,plugins
4849
EOF
4950
(cd "$TEMP" && find payload -type f -print | LC_ALL=C sort | while IFS= read -r FILE; do shasum -a 256 "$FILE"; done > SHA256SUMS)
50-
ARCHIVE="$DESTINATION/wepush-next-$STAMP.tar.gz"
51+
ARCHIVE="$DESTINATION/wepush-next-$STAMP-$BACKUP_ID.tar.gz"
5152
tar -C "$TEMP" -czf "$ARCHIVE" BACKUP-MANIFEST SHA256SUMS payload
5253
chmod 0600 "$ARCHIVE"
5354
"$(dirname -- "$0")/restore.sh" --validate-only "$ARCHIVE"

‎next/distribution/src/main/distribution/install/windows/backup.ps1‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ try {
3939
"$((Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant()) $relative"
4040
}
4141
$checksums | Set-Content -Encoding ascii "$temporary\SHA256SUMS"
42-
$archive = Join-Path $Destination "wepush-next-$stamp.zip"
42+
$backupId = [Guid]::NewGuid().ToString("N").Substring(0, 8)
43+
$archive = Join-Path $Destination "wepush-next-$stamp-$backupId.zip"
4344
Compress-Archive -Path "$temporary\*" -DestinationPath $archive -CompressionLevel Optimal
4445
& "$PSScriptRoot\restore.ps1" -ValidateOnly -Archive $archive
4546
Write-Output $archive

‎next/docs/releases/1.0.0.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- Agent Event/Completion Outbox 在模拟磁盘不可写时保持内存与已持久化状态一致,不跳过事件序号或误删未确认结果。
1919
- Agent 断网后的业务事件重放、进程崩溃后的 `UNKNOWN` Completion、Lease/Fence 恢复和失联超时继续由自动化测试覆盖。
2020
- Java 21/25 × SQLite/PostgreSQL 长稳矩阵持续检查 Installation Health 和 System API。
21-
- Linux、macOS、Windows 运维自测覆盖 Beta 成功升级、升级失败自动回退、备份恢复、默认卸载保留数据以及显式 Purge。
21+
- Linux、macOS、Windows 运维自测覆盖 Beta 成功升级、升级失败自动回退、可连续创建且不会同名碰撞的备份恢复、默认卸载保留数据以及显式 Purge。
2222

2323
## 安装与发行物
2424

0 commit comments

Comments
 (0)