@@ -206,7 +206,12 @@ function AutomaticBackupSelector({
206
206
try {
207
207
if ( periodicBackup === null ) {
208
208
// Enable automatic backups
209
- const defaultCronspec = "0 0 * * *" ;
209
+
210
+ // We randomize the default cron spec to spread out the backups
211
+ // of users that don’t specify a custom time
212
+ const randomHour = Math . floor ( Math . random ( ) * 24 ) ;
213
+ const randomMinute = Math . floor ( Math . random ( ) * 60 ) ;
214
+ const defaultCronspec = `${ randomMinute } ${ randomHour } * * *` ;
210
215
await configurePeriodicBackup ( { cronspec : defaultCronspec } ) ;
211
216
} else {
212
217
// Disable automatic backups
@@ -307,7 +312,7 @@ export function BackupScheduleSelector({
307
312
< BackupScheduleSelectorInner
308
313
defaultValue = { date }
309
314
defaultPeriodicity = { isWeekly ? "weekly" : "daily" }
310
- defaultDayOfWeek = { dayOfWeekNum ?? 0 }
315
+ defaultDayOfWeek = { dayOfWeekNum }
311
316
onClose = { close }
312
317
deployment = { deployment }
313
318
/>
@@ -325,7 +330,7 @@ export function BackupScheduleSelectorInner({
325
330
} : {
326
331
defaultValue : Date ;
327
332
defaultPeriodicity : "daily" | "weekly" ;
328
- defaultDayOfWeek : number ;
333
+ defaultDayOfWeek : number | null ;
329
334
onClose : ( ) => void ;
330
335
deployment : DeploymentResponse ;
331
336
} ) {
@@ -339,7 +344,13 @@ export function BackupScheduleSelectorInner({
339
344
const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
340
345
341
346
const [ periodicity , setPeriodicity ] = useState ( defaultPeriodicity ) ;
342
- const [ selectedDow , setSelectedDow ] = useState ( defaultDayOfWeek ) ;
347
+ const [ selectedDow , setSelectedDow ] = useState (
348
+ ( ) =>
349
+ defaultDayOfWeek ??
350
+ // We randomize the default day of week to spread out the backups
351
+ // of users that don’t specify a custom time
352
+ Math . floor ( Math . random ( ) * 7 ) ,
353
+ ) ;
343
354
344
355
return (
345
356
< form
0 commit comments