Skip to content

Commit

Permalink
fix: don't add the storage name twice to the scheduled backup name
Browse files Browse the repository at this point in the history
Don't add the storage name twice to the scheduled backup name

Adding a storage name twice might make a job name longer than 63 characters
and break backup creation
  • Loading branch information
s10 committed Dec 23, 2024
1 parent 65f7f15 commit f5e5b85
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/naming/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,22 @@ func trimJobName(name string) string {
}

func ScheduledBackupName(crName, storageName, schedule string) string {
result := "cron-"
result := "cron"

if len(crName) > 16 {
result += crName[:16]
result += "-" + crName[:16]
} else {
result += crName
result += "-" + crName
}

if len(storageName) > 16 {
result += storageName[:16]
result += "-" + storageName[:16]
} else {
result += storageName
result += "-" + storageName
}

result += "-" + storageName + "-"
tnow := time.Now()
result += fmt.Sprintf("%d%d%d%d%d%d", tnow.Year(), tnow.Month(), tnow.Day(), tnow.Hour(), tnow.Minute(), tnow.Second())
result += "-" + fmt.Sprintf("%d%d%d%d%d%d", tnow.Year(), tnow.Month(), tnow.Day(), tnow.Hour(), tnow.Minute(), tnow.Second())
result += "-" + strconv.FormatUint(uint64(crc32.ChecksumIEEE([]byte(schedule))), 32)[:5]
return result
}

0 comments on commit f5e5b85

Please sign in to comment.