Skip to content

Commit 7308d3e

Browse files
author
anton.voskresensky
committed
fix
1 parent a1dbebf commit 7308d3e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

commands/snapshotsbackfill.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,24 @@ func runSnapshotsBackfill(cmd *cobra.Command, args []string) error {
264264
snapshotGroups := utils.GroupIndicesForSnapshots(indicesToSnapshot, indicesConfig, snapshotDate)
265265

266266
if unknownConfig.Snapshot && !unknownConfig.ManualSnapshot && len(unknownIndices) > 0 {
267-
randomSuffix := utils.GenerateRandomAlphanumericString(6)
267+
unknownSnapshotName := "unknown-" + snapshotDate
268+
existingForDate, err := utils.GetSnapshotsIgnore404(client, defaultRepo, "*"+snapshotDate+"*")
269+
if err != nil {
270+
existingForDate = nil
271+
}
272+
if existingForDate == nil {
273+
existingForDate = []opensearch.Snapshot{}
274+
}
275+
276+
state, exists := utils.GetSnapshotStateByName(unknownSnapshotName, existingForDate)
277+
snapshotName := unknownSnapshotName
278+
if exists && state == "SUCCESS" {
279+
randomSuffix := utils.GenerateRandomAlphanumericString(6)
280+
snapshotName = "unknown-" + randomSuffix + "-" + snapshotDate
281+
}
282+
268283
snapshotGroups = append(snapshotGroups, utils.SnapshotGroup{
269-
SnapshotName: "unknown-" + randomSuffix + "-" + snapshotDate,
284+
SnapshotName: snapshotName,
270285
Indices: unknownIndices,
271286
Pattern: "unknown",
272287
Kind: "unknown",

0 commit comments

Comments
 (0)