Hi
I have a number of tagged and untagged snapshots. I would like automate forget/prune of untagged snapshots only.
At the moment it appears I cannot specify an “untagged” snapshot, either for listing snapshots, or forget. It’s either lists everything, or a selection of known tags.
Based on my reading, I would have to list all snapshots, collect all possible tag names, then add --keep-tag=<tag list>
to my forget command.
Is this correct? or an I doing something wrong?
Thanks
There does not appear to be any way to match all untagged snapshots, so I have submitted a pull request to support such a feature.
restic:master
← systemmonkey42:feature/untagged
opened 02:15AM - 15 Jul 21 UTC
<!--
Thank you very much for contributing code or documentation to restic! Plea… se
fill out the following questions to make it easier for us to review your
changes.
-->
What does this PR change? What problem does it solve?
-----------------------------------------------------
Add support for specifying an EMPTY tag for `--tag` and `--keep-tag` which implicitly matches all untagged snapshots.
<!--
Describe the changes and their purpose here, as detailed as needed.
-->
Was the change previously discussed in an issue or on the forum?
----------------------------------------------------------------
https://forum.restic.net/t/help-with-forgetting-untagged-snapshots/4173
See #3456
<!--
Link issues and relevant forum posts here.
If this PR resolves an issue on GitHub, use "Closes #1234" so that the issue
is closed automatically when this PR is merged.
-->
Checklist
---------
<!--
You do not need to check all the boxes below all at once. Feel free to take
your time and add more commits. If you're done and ready for review, please
check the last box. Enable a checkbox by replacing [ ] with [x].
-->
- [x] I have read the [contribution guidelines](https://github.com/restic/restic/blob/master/CONTRIBUTING.md#providing-patches).
- [x] I have [enabled maintainer edits](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
- [x] I have added tests for all code changes.
- [ ] I have added documentation for relevant changes (in the manual).
- [ ] There's a new file in `changelog/unreleased/` that describes the changes for our users (see [template](https://github.com/restic/restic/blob/master/changelog/TEMPLATE)).
- [x] I have run `gofmt` on the code in all commits.
- [ ] All commit messages are formatted in the same style as [the other commits in the repo](https://github.com/restic/restic/blob/master/CONTRIBUTING.md#git-commits).
- [x] I'm done! This pull request is ready for review.
rawtaz
July 15, 2021, 11:27am
3
It’s really simple to filter out the snapshots that have no tags using jq
, run the restic snapshots
command and pipe the output through jq -r '.[] | select(has("tags") | not).id'
to get the list of snapshots that contains no tags.
As an update, I’m thinking my policy needs to change to ensure all backups are tagged with something.
It makes much more sense to tag my system backups and apply policy to that tag directly.
Thanks.