Class WorldBackupService
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Creates and restores zip backups of a server's world folder — the "level-name" directory from server.properties ("world" by default). That single folder holds every dimension, including the modern layout that nests them under "dimensions/", so zipping it alone is a complete backup. Backups live in "<server folder>/backups/"; old ones beyond the configured retention are pruned after each new one.
public class WorldBackupService
- Inheritance
-
WorldBackupService
- Inherited Members
Methods
CreateBackupAsync(ServerConfig, string, IProgress<string>?, CancellationToken, string?)
Zips the world folder into backups/. No-op (returns null) if the world doesn't exist yet — a
server that has never been started has nothing to back up. Prunes old backups beyond
BackupRetention afterward; protectFromPruning (if
given) is never deleted by that pruning, even if it would otherwise have aged out — used by
RestoreBackupAsync(ServerConfig, string, IProgress<string>?, CancellationToken) so its own safety-net backup can never delete the very backup
being restored from.
public Task<string?> CreateBackupAsync(ServerConfig config, string trigger, IProgress<string>? log = null, CancellationToken ct = default, string? protectFromPruning = null)
Parameters
configServerConfigtriggerstringlogIProgress<string>ctCancellationTokenprotectFromPruningstring
Returns
GetLevelName(ServerConfig)
The world folder name (server.properties' level-name, "world" if unset).
public string GetLevelName(ServerConfig config)
Parameters
configServerConfig
Returns
ListBackups(ServerConfig)
All backups for this server, newest first.
public IReadOnlyList<WorldBackupService.BackupInfo> ListBackups(ServerConfig config)
Parameters
configServerConfig
Returns
RestoreBackupAsync(ServerConfig, string, IProgress<string>?, CancellationToken)
Restores a backup, replacing the current world folder entirely. Makes a safety backup of the
CURRENT state first (trigger "before-restore") so the restore itself can be undone. That
safety backup's own retention pruning is not allowed to delete zipPath —
otherwise a tight retention could prune the very backup being restored from before it's read.
public Task RestoreBackupAsync(ServerConfig config, string zipPath, IProgress<string>? log = null, CancellationToken ct = default)
Parameters
configServerConfigzipPathstringlogIProgress<string>ctCancellationToken