bug: interrupted upgrade-state backups leave unbounded .tar.gz.tmp files included in Home Assistant backups
Pre-flight checks
- [x] I updated to the latest add-on version and restarted it.
- [x] I checked the docs/troubleshooting section first.
What happened?
If the add-on is stopped or killed while backup_state_before_upgrade() is creating a pre-upgrade archive, the current openclaw-state-*.tar.gz.tmp file can remain in /config/.openclaw/upgrade-backups.
On the next start, the script generates a new timestamped filename, so rm -f "$temporary" only targets the new path and does not remove older temporary files. The retention function only matches completed *.tar.gz archives, not *.tar.gz.tmp files.
In the affected installation this accumulated 172 temporary archives using about 104 GiB. Home Assistant Supervisor then included them in an add-on backup because backup_exclude has no matching rule for these temporary files.
The internal pre-upgrade archive itself excludes ./upgrade-backups, so this is not recursive self-inclusion; it is unbounded accumulation of separate interrupted archives, followed by inclusion in Home Assistant backups.
What did you expect to happen?
- An interrupted pre-upgrade archive should be removed during shutdown or the next add-on start.
- Stale
openclaw-state-*.tar.gz.tmpfiles should not accumulate. - In-progress temporary archives should be excluded from Home Assistant backups.
- Completed
*.tar.gzrollback archives andstarted-*markers should remain untouched.
Steps to reproduce
- Run add-on version
0.5.94with existing OpenClaw state and nostarted-<new-version>marker. - Start the add-on so the log reaches
Creating pre-upgrade state backup.... - Stop or kill the add-on/container before
tarcompletes, so PID 1 cannot execute its normal failure cleanup. - Confirm that
/config/.openclaw/upgrade-backups/openclaw-state-*-before-<version>.tar.gz.tmpremains. - Restart later. A new timestamped
.tmpfile is created; the stale file is not removed. - Repeat to accumulate more temporary files.
- Create a Home Assistant backup containing this add-on and observe that the stale
.tmpfiles are included.
Add-on version
0.5.94
OpenClaw version (if known)
2026.9.9 (bcfc888)
Access mode
lan_https
Relevant add-on configuration (redacted)
access_mode: lan_https
timezone: Europe/Kyiv
Add-on logs
The original interrupted-run logs are no longer available after local cleanup. The relevant startup line before an interrupted archive is:
INFO: Creating pre-upgrade state backup for OpenClaw 2026.9.9...
Observed before cleanup:
$ find /config/.openclaw/upgrade-backups -maxdepth 1 -type f -name 'openclaw-state-*.tar.gz.tmp' | wc -l
172
$ du -sh /config/.openclaw/upgrade-backups
approximately 104 GiB
After deleting only the stale *.tar.gz.tmp files, three completed rollback archives and all started-* markers remained; the directory size dropped to about 1.1 GiB.
Additional context
Verified against current main at commit d3b414dc852e572a22def7ba990480c9ccccf829:
run.sh: the temporary filename includes a fresh timestamp; startup only removes that newly calculated path.- Cleanup after
tarfailure cannot run when the container/PID 1 is terminated. prune_upgrade_backups()matches onlyopenclaw-state-*.tar.gz.config.yamlbackup_excludehas no rule for.openclaw/upgrade-backups/*.tar.gz.tmp.
Suggested minimal root-cause fix:
- After acquiring the existing startup lock, remove stale files matching only
openclaw-state-*.tar.gz.tmpfrom the upgrade-backup directory before checking/creating the next archive. - Add a narrowly scoped
backup_excludepattern for.openclaw/upgrade-backups/*.tar.gz.tmpso a Home Assistant backup cannot capture the currently written archive. - Preserve completed
*.tar.gzarchives andstarted-*markers.
Environment: Home Assistant add-on container on Debian 12, aarch64.