2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 06:07:44 +00:00

snapshots sorted by timestamp

This commit is contained in:
arjunajesh 2023-07-16 13:51:24 -04:00 committed by Michael Eischer
parent 98fb56baa6
commit 32f5ee6f4e
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