mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 12:32:31 +01:00
New: Add version and timestamp to backup archive
(cherry picked from commit ed3d880974ae6a1430866eebaf72533f35258f6f)
This commit is contained in:
parent
9a23b7f0fc
commit
e0ad573e7f
@ -69,7 +69,8 @@ public void Backup(BackupType backupType)
|
|||||||
_diskProvider.EnsureFolder(_backupTempFolder);
|
_diskProvider.EnsureFolder(_backupTempFolder);
|
||||||
_diskProvider.EnsureFolder(GetBackupFolder(backupType));
|
_diskProvider.EnsureFolder(GetBackupFolder(backupType));
|
||||||
|
|
||||||
var backupFilename = string.Format("radarr_backup_v{0}_{1:yyyy.MM.dd_HH.mm.ss}.zip", BuildInfo.Version, DateTime.Now);
|
var dateNow = DateTime.Now;
|
||||||
|
var backupFilename = $"radarr_backup_v{BuildInfo.Version}_{dateNow:yyyy.MM.dd_HH.mm.ss}.zip";
|
||||||
var backupPath = Path.Combine(GetBackupFolder(backupType), backupFilename);
|
var backupPath = Path.Combine(GetBackupFolder(backupType), backupFilename);
|
||||||
|
|
||||||
Cleanup();
|
Cleanup();
|
||||||
@ -81,7 +82,7 @@ public void Backup(BackupType backupType)
|
|||||||
|
|
||||||
BackupConfigFile();
|
BackupConfigFile();
|
||||||
BackupDatabase();
|
BackupDatabase();
|
||||||
CreateVersionInfo();
|
CreateVersionInfo(dateNow);
|
||||||
|
|
||||||
_logger.ProgressDebug("Creating backup zip");
|
_logger.ProgressDebug("Creating backup zip");
|
||||||
|
|
||||||
@ -208,11 +209,15 @@ private void BackupConfigFile()
|
|||||||
_diskTransferService.TransferFile(configFile, tempConfigFile, TransferMode.Copy);
|
_diskTransferService.TransferFile(configFile, tempConfigFile, TransferMode.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateVersionInfo()
|
private void CreateVersionInfo(DateTime dateNow)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
var tempFile = Path.Combine(_backupTempFolder, "INFO");
|
||||||
|
|
||||||
builder.AppendLine(BuildInfo.Version.ToString());
|
var builder = new StringBuilder();
|
||||||
|
builder.AppendLine($"v{BuildInfo.Version}");
|
||||||
|
builder.AppendLine($"{dateNow:yyyy-MM-dd HH:mm:ss}");
|
||||||
|
|
||||||
|
_diskProvider.WriteAllText(tempFile, builder.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanupOldBackups(BackupType backupType)
|
private void CleanupOldBackups(BackupType backupType)
|
||||||
|
Loading…
Reference in New Issue
Block a user