Skip to content

Remove a tar backup that failed instead of keeping it - #343

Merged
itzg merged 1 commit into
itzg:masterfrom
jayhemnani9910:fix/remove-failed-tar-backup
Dec 3, 2026
Merged

itzg merged 1 commit into
itzg:masterfrom
jayhemnani9910:fix/remove-failed-tar-backup

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

When tar fails with a fatal error, for example because the backup volume is full, the partly written archive stays in DEST_DIR. The count prune then counts it as the newest backup and deletes a good one to make room for it. The latest link also moves to the broken file, so restore-tar-backup and latest.tar.gz both pick it.

Run with three good backups, PRUNE_BACKUPS_COUNT=3 and a full disk (simulated with ulimit -f):

ERROR Backup failed with exit code 2
INFO removed '.../world-20261201-000000.tar.gz'

That leaves two good backups and a truncated world-20261203-093159.tar.gz (gzip -t: unexpected end of file). While the disk stays full, every interval repeats this, until only broken archives are left.

On a tar exit code above 1, backup() now deletes ${outFile} and returns before updating the latest link. Exit code 1 (files changed while being read; the archive is fine) behaves as before.

Testing: ran backup-loop.sh directly with rcon-cli stubbed, before and after. With this change, the incomplete archive is removed and all three good backups are kept. A normal run still writes a valid archive and prunes the oldest. shellcheck shows no new findings.

@itzg itzg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@itzg itzg added the bug Something isn't working label Dec 3, 2026
@itzg
itzg merged commit d864fe4 into itzg:master Dec 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants