Class BackupSchedule
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Decides when a running server is due for an automatic backup.
public static class BackupSchedule
- Inheritance
-
BackupSchedule
- Inherited Members
Remarks
Kept apart from the timer that asks it so that the rule can be tested at any hour of any day, rather than by waiting an hour and hoping.
Skip is the reason this is not just a subtraction. A server left running overnight with nobody on it barely changes — Minecraft only ticks chunks that somebody is near — so backing it up every hour would fill the disk with copies of the same world. Skipping moves the clock on instead, so the next backup lands an interval after somebody actually turns up rather than the moment they do.
Fields
DefaultMinutes
public const int DefaultMinutes = 60
Field Value
MaxMinutes
public const int MaxMinutes = 1440
Field Value
MinMinutes
public const int MinMinutes = 5
Field Value
Methods
Clamp(int)
Brings a stored interval back into range: settings.json is a file people can edit, and a zero there would otherwise mean "back up on every tick".
public static int Clamp(int minutes)
Parameters
minutesint
Returns
Due(DateTime, DateTime, int, bool, bool)
Whether a backup is due, given when the last one was and whether anyone has played since.
public static BackupDue Due(DateTime nowUtc, DateTime lastUtc, int intervalMinutes, bool playedSince, bool enabled = true)
Parameters
nowUtcDateTimeThe current time.
lastUtcDateTimeWhen the last automatic backup was made, or the server started.
intervalMinutesintThe configured interval; clamped here, so an odd stored value is harmless.
playedSinceboolWhether anybody has been connected since
lastUtc.enabledboolWhether automatic backups are switched on for this server at all.