feat(backup): 玩过的世界每天在停服后自动打一个定时恢复点,按服按 owner 保留 7 个、90 天过期

This commit is contained in:
Lemon-miaow committed 2026-09-27 00:02:49 +08:00
1 parent d6e1a6464c
commit 8ef7112dab
29 files changed
+1028 -59

No files matched your search

+15
View File
@@ -205,6 +205,21 @@ func (b *Backuper) BackupThenRestore(ctx context.Context, serverName, formerOwne
return nil
}
// BackupScheduled enqueues the daily restore point of a world (api.BackupScheduler):
// a backup Job like Backup's, recorded as a scheduled backup and pruned to
// [archive] scheduled_keep, so the owner's own backups keep their count.
func (b *Backuper) BackupScheduled(ctx context.Context, serverName, formerOwner string) error {
p := b.jobParams(serverName, formerOwner)
p.Scheduled = true
if err := b.Jobs.CreateBackupJob(ctx, p); err != nil {
if errors.Is(err, ErrAlreadyExists) {
return nil // suffix collision — treat as enqueued
}
return err
}
return nil
}
// jobNameSuffix is a short random hex tag that makes each backup Job name unique.
// 32 bits is ample: collisions only matter within a single Job's TTL window across
// a handful of manual backups.