ServerBackup
A static class in TavernLib, TavernLib.Backend.Server.
Timed zip backups of the server's world folder (Servers\-1) into its Backups folder, for servers not run by the launcher. Server; started from Tavern unless /launcherauth is given.
- Listed in TavernLib.Backend.Server
- Nested types
BackupResult - Documented in Internals
Fields
8 private and internal fields
Properties
| Member | What it is |
|---|---|
static string ServerDirectory { get; } | A Township Tale\Servers\-1, the Tavern server's world folder. |
Methods
10 private and internal methods
| Member | What it is |
|---|---|
internal static ServerBackup.BackupResult CreateBackup(string serverDir, DateTime now) | Internal: zips the folder (leaving out Backups and Logs) to ServerBackup_<time>.zip. Files in use are skipped; any other failure leaves no zip. |
private static IEnumerable<string> EnumerateBackupFiles(string root) (iterator) | Yields every file under the server folder, skipping the excluded top-level folders and anything it can't list. |
private static string FormatSize(long bytes) | Turns a byte count into a short MB or KB text for the log. |
internal static bool IsDue(string serverDir, float hours, DateTime nowUtc) | Internal: true when backups are on and the newest backup is at least that many hours old, or there is none yet. |
internal static string[] ListBackups(string serverDir) | Internal: the finished backup zips in the Backups folder, oldest first. |
internal static int Prune(string serverDir, int maxBackups) | Internal: deletes the oldest backups so at most that many remain (0 keeps all). Returns how many it removed. |
internal static void Start() | Internal: starts a timer that checks once a minute whether a backup is due. |
internal static void Tick() | Internal: one check. Re-reads server_backup_time and server_backup_max_backups, backs up if due, then prunes. Never runs two at once. |
private static bool TryReadSettings(out float hours, out int maxBackups) | Reads the backup interval in hours and the number of backups to keep from server_settings.json; false if it can't be read. |
private static DateTimeOffset ZipTime(DateTime time) | Clamps a file time into the 1980 to 2107 range a zip can store. |