2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00
snapshots sorted by timestamp in restic find
This commit is contained in:
Michael Eischer 2023-07-23 11:00:41 +00:00 committed by GitHub
commit 1fe1ec40a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,7 @@
Enhancement: Snapshots are sorted by timestamp in the output of `restic find`
The `find` command printed snapshots in an arbitrary order. Now restic prints
the snapshots sorted by timestamp.
https://github.com/restic/restic/issues/1495
https://github.com/restic/restic/pull/4409

View File

@ -621,7 +621,16 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
}
}
var filteredSnapshots []*restic.Snapshot
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, opts.Snapshots) {
filteredSnapshots = append(filteredSnapshots, sn)
}
sort.Slice(filteredSnapshots, func(i, j int) bool {
return filteredSnapshots[i].Time.Before(filteredSnapshots[j].Time)
})
for _, sn := range filteredSnapshots {
if f.blobIDs != nil || f.treeIDs != nil {
if err = f.findIDs(ctx, sn); err != nil && err.Error() != "OK" {
return err