From fe2596dc0e389c0496a384cc1893fddd4742ed37 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Mon, 19 May 2025 03:39:04 +0300 Subject: Add Full system backup feature (#13945) --- .../SystemBackupService/BackupManifestDto.cs | 34 +++++++++++++++ .../SystemBackupService/BackupOptionsDto.cs | 24 +++++++++++ .../SystemBackupService/BackupRestoreRequestDto.cs | 15 +++++++ .../SystemBackupService/IBackupService.cs | 48 ++++++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 MediaBrowser.Controller/SystemBackupService/BackupManifestDto.cs create mode 100644 MediaBrowser.Controller/SystemBackupService/BackupOptionsDto.cs create mode 100644 MediaBrowser.Controller/SystemBackupService/BackupRestoreRequestDto.cs create mode 100644 MediaBrowser.Controller/SystemBackupService/IBackupService.cs (limited to 'MediaBrowser.Controller/SystemBackupService') diff --git a/MediaBrowser.Controller/SystemBackupService/BackupManifestDto.cs b/MediaBrowser.Controller/SystemBackupService/BackupManifestDto.cs new file mode 100644 index 000000000..b094ec275 --- /dev/null +++ b/MediaBrowser.Controller/SystemBackupService/BackupManifestDto.cs @@ -0,0 +1,34 @@ +using System; + +namespace MediaBrowser.Controller.SystemBackupService; + +/// +/// Manifest type for backups internal structure. +/// +public class BackupManifestDto +{ + /// + /// Gets or sets the jellyfin version this backup was created with. + /// + public required Version ServerVersion { get; set; } + + /// + /// Gets or sets the backup engine version this backup was created with. + /// + public required Version BackupEngineVersion { get; set; } + + /// + /// Gets or sets the date this backup was created with. + /// + public required DateTimeOffset DateCreated { get; set; } + + /// + /// Gets or sets the path to the backup on the system. + /// + public required string Path { get; set; } + + /// + /// Gets or sets the contents of the backup archive. + /// + public required BackupOptionsDto Options { get; set; } +} diff --git a/MediaBrowser.Controller/SystemBackupService/BackupOptionsDto.cs b/MediaBrowser.Controller/SystemBackupService/BackupOptionsDto.cs new file mode 100644 index 000000000..228839a1d --- /dev/null +++ b/MediaBrowser.Controller/SystemBackupService/BackupOptionsDto.cs @@ -0,0 +1,24 @@ +using System; + +namespace MediaBrowser.Controller.SystemBackupService; + +/// +/// Defines the optional contents of the backup archive. +/// +public class BackupOptionsDto +{ + /// + /// Gets or sets a value indicating whether the archive contains the Metadata contents. + /// + public bool Metadata { get; set; } + + /// + /// Gets or sets a value indicating whether the archive contains the Trickplay contents. + /// + public bool Trickplay { get; set; } + + /// + /// Gets or sets a value indicating whether the archive contains the Subtitle contents. + /// + public bool Subtitles { get; set; } +} diff --git a/MediaBrowser.Controller/SystemBackupService/BackupRestoreRequestDto.cs b/MediaBrowser.Controller/SystemBackupService/BackupRestoreRequestDto.cs new file mode 100644 index 000000000..263fa00c8 --- /dev/null +++ b/MediaBrowser.Controller/SystemBackupService/BackupRestoreRequestDto.cs @@ -0,0 +1,15 @@ +using System; +using MediaBrowser.Common.Configuration; + +namespace MediaBrowser.Controller.SystemBackupService; + +/// +/// Defines properties used to start a restore process. +/// +public class BackupRestoreRequestDto +{ + /// + /// Gets or Sets the name of the backup archive to restore from. Must be present in . + /// + public required string ArchiveFileName { get; set; } +} diff --git a/MediaBrowser.Controller/SystemBackupService/IBackupService.cs b/MediaBrowser.Controller/SystemBackupService/IBackupService.cs new file mode 100644 index 000000000..0c586d811 --- /dev/null +++ b/MediaBrowser.Controller/SystemBackupService/IBackupService.cs @@ -0,0 +1,48 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using MediaBrowser.Controller.SystemBackupService; + +namespace Jellyfin.Server.Implementations.SystemBackupService; + +/// +/// Defines an interface to restore and backup the jellyfin system. +/// +public interface IBackupService +{ + /// + /// Creates a new Backup zip file containing the current state of the application. + /// + /// The backup options. + /// A task. + Task CreateBackupAsync(BackupOptionsDto backupOptions); + + /// + /// Gets a list of backups that are available to be restored from. + /// + /// A list of backup paths. + Task EnumerateBackups(); + + /// + /// Gets a single backup manifest if the path defines a valid Jellyfin backup archive. + /// + /// The path to be loaded. + /// The containing backup manifest or null if not existing or compatiable. + Task GetBackupManifest(string archivePath); + + /// + /// Restores an backup zip file created by jellyfin. + /// + /// Path to the archive. + /// A Task. + /// Thrown when an invalid or missing file is specified. + /// Thrown when attempt to load an unsupported backup is made. + /// Thrown for errors during the restore. + Task RestoreBackupAsync(string archivePath); + + /// + /// Schedules a Restore and restarts the server. + /// + /// The path to the archive to restore from. + void ScheduleRestoreAndRestartServer(string archivePath); +} -- cgit v1.2.3