Table of Contents

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

int

MaxMinutes

public const int MaxMinutes = 1440

Field Value

int

MinMinutes

public const int MinMinutes = 5

Field Value

int

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

minutes int

Returns

int

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

nowUtc DateTime

The current time.

lastUtc DateTime

When the last automatic backup was made, or the server started.

intervalMinutes int

The configured interval; clamped here, so an odd stored value is harmless.

playedSince bool

Whether anybody has been connected since lastUtc.

enabled bool

Whether automatic backups are switched on for this server at all.

Returns

BackupDue