Skip to content

Skip the latest link when pruning tar backups by count - #341

Merged
itzg merged 1 commit into
itzg:masterfrom
jayhemnani9910:fix/tar-prune-count-latest-link
Nov 28, 2026
Merged

itzg merged 1 commit into
itzg:masterfrom
jayhemnani9910:fix/tar-prune-count-latest-link

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

With the tar method, LINK_LATEST=true and PRUNE_BACKUPS_COUNT=N, the count prune keeps only N-1 archives. _find_extra_backups matches *.tar.gz, and that includes the latest.tar.gz symlink, which is always the newest file. With PRUNE_BACKUPS_COUNT=1, every run deletes the archive it just wrote. All that is left is a dangling latest.tar.gz, so no backup exists:

INFO Pruning backup files to keep only the latest 1 backups
INFO removed '/tmp/dest/world-20261127-191714.tar.gz'

Adding -type f to that find leaves the link out of the count. The day-based prune and the rsync method are not affected.

Testing: added tests/test.prune-count.tar.sh and a step for it in verify.yml. It runs the image twice with LINK_LATEST=true PRUNE_BACKUPS_COUNT=1, then checks that one archive is left and that latest.tar.gz opens. It fails on master (no archive left, link dangling) and passes with the change. test.simple.tar.sh fails the exclude check on my machine both with and without the change, so I couldn't use it here.

@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 for fixing that

@itzg itzg added the bug Something isn't working label Nov 28, 2026
@itzg
itzg merged commit 936ff58 into itzg:master Nov 28, 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