Skip to content

Check that there are enough snapshots before diff #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2025

Conversation

johnmaguire
Copy link
Contributor

The first run after init'ing tends to cause a systemd failure due to not having enough snapshots for statistics.

Copy link
Owner

@erikw erikw left a comment

Choose a reason for hiding this comment

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

Good idea! Just some git diff questions to review.

snapshotId=$(echo "$latest_snapshots" | cut -d ' ' -f2)
statsMsg="Added: ${added}. Removed: ${removed}. Snap size: ${snapshot_size}"
fi

latest_snapshot_diff=$(echo "$latest_snapshots" | xargs restic diff)
Copy link
Owner

Choose a reason for hiding this comment

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

It looks like you forgot to remove the snapshot calculation lines, that are now copied to the else branch.

Probably the echo "$statsMsg" and 2 lines below should also be in the new else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, sorry about that! I have a slightly modified copy of this in my Ansible repository and I forgot to remove the snapshot calculation lines when moving it over to this repository.

Good point on the following two lines - when I tested it as-is, no errors were returned, but it doesn't make sense to call these functions without the data.

Delete duplicate code and pull usage of the calculated stats into the
conditional block.
Copy link
Owner

@erikw erikw left a comment

Choose a reason for hiding this comment

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

This is better. 👍 thanks

@erikw erikw merged commit 1e393d6 into erikw:main Aug 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants