diff --git a/src/NzbDrone.Common/PathExtensions.cs b/src/NzbDrone.Common/PathExtensions.cs
index 5bf143796..763b1d1c0 100644
--- a/src/NzbDrone.Common/PathExtensions.cs
+++ b/src/NzbDrone.Common/PathExtensions.cs
@@ -18,6 +18,7 @@ namespace NzbDrone.Common
private static readonly string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup" + Path.DirectorySeparatorChar;
+ private static readonly string UPDATE_BACKUP_APPDATA_FOLDER_NAME = "nzbdrone_appdata_backup" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar;
@@ -155,6 +156,11 @@ namespace NzbDrone.Common
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_BACKUP_FOLDER_NAME);
}
+ public static string GetUpdateBackUpAppDataFolder(this IAppFolderInfo appFolderInfo)
+ {
+ return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_BACKUP_APPDATA_FOLDER_NAME);
+ }
+
public static string GetUpdatePackageFolder(this IAppFolderInfo appFolderInfo)
{
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_PACKAGE_FOLDER_NAME);
diff --git a/src/NzbDrone.Update/NzbDrone.Update.csproj b/src/NzbDrone.Update/NzbDrone.Update.csproj
index d09ab8021..908102ff9 100644
--- a/src/NzbDrone.Update/NzbDrone.Update.csproj
+++ b/src/NzbDrone.Update/NzbDrone.Update.csproj
@@ -60,6 +60,7 @@
+
diff --git a/src/NzbDrone.Update/UpdateApp.cs b/src/NzbDrone.Update/UpdateApp.cs
index 83531b153..35d7febca 100644
--- a/src/NzbDrone.Update/UpdateApp.cs
+++ b/src/NzbDrone.Update/UpdateApp.cs
@@ -50,10 +50,10 @@ namespace NzbDrone.Update
public void Start(string[] args)
{
- int processId = ParseProcessId(args);
+ var processId = ParseProcessId(args);
var exeFileInfo = new FileInfo(_processProvider.GetProcessById(processId).StartPath);
- string targetFolder = exeFileInfo.Directory.FullName;
+ var targetFolder = exeFileInfo.Directory.FullName;
logger.Info("Starting update process. Target Path:{0}", targetFolder);
_installUpdateService.Start(targetFolder);
diff --git a/src/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs b/src/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs
index 3787b25d3..a934e6fc6 100644
--- a/src/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs
+++ b/src/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs
@@ -7,7 +7,7 @@ namespace NzbDrone.Update.UpdateEngine
{
public interface IBackupAndRestore
{
- void BackUp(string source);
+ void Backup(string source);
void Restore(string target);
}
@@ -24,7 +24,7 @@ namespace NzbDrone.Update.UpdateEngine
_logger = logger;
}
- public void BackUp(string source)
+ public void Backup(string source)
{
_logger.Info("Creating backup of existing installation");
_diskProvider.CopyFolder(source, _appFolderInfo.GetUpdateBackUpFolder());
diff --git a/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs b/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs
new file mode 100644
index 000000000..42d0dcad5
--- /dev/null
+++ b/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs
@@ -0,0 +1,44 @@
+using System.IO;
+using NLog;
+using NzbDrone.Common;
+using NzbDrone.Common.Disk;
+using NzbDrone.Common.EnvironmentInfo;
+
+namespace NzbDrone.Update.UpdateEngine
+{
+ public interface IBackupAppData
+ {
+ void Backup();
+ }
+
+ public class BackupAppData : IBackupAppData
+ {
+ private readonly IAppFolderInfo _appFolderInfo;
+ private readonly IDiskProvider _diskProvider;
+ private readonly Logger _logger;
+
+ public BackupAppData(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
+ {
+ _appFolderInfo = appFolderInfo;
+ _diskProvider = diskProvider;
+ _logger = logger;
+ }
+
+ public void Backup()
+ {
+ _logger.Info("Backing up appdata (database/config)");
+ var appDataPath = _appFolderInfo.GetAppDataPath();
+ var backupFolderAppData = _appFolderInfo.GetUpdateBackUpAppDataFolder();
+ var binFolder = Path.Combine(backupFolderAppData, "bin");
+
+ _diskProvider.CreateFolder(backupFolderAppData);
+ _diskProvider.CopyFolder(appDataPath, backupFolderAppData);
+
+ if (_diskProvider.FolderExists(binFolder))
+ {
+ _logger.Info("Deleting bin folder from appdata");
+ _diskProvider.DeleteFolder(binFolder, true);
+ }
+ }
+ }
+}
diff --git a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs
index 0e6001677..f1b731e34 100644
--- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs
+++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs
@@ -19,17 +19,25 @@ namespace NzbDrone.Update.UpdateEngine
private readonly ITerminateNzbDrone _terminateNzbDrone;
private readonly IAppFolderInfo _appFolderInfo;
private readonly IBackupAndRestore _backupAndRestore;
+ private readonly IBackupAppData _backupAppData;
private readonly IStartNzbDrone _startNzbDrone;
private readonly Logger _logger;
- public InstallUpdateService(IDiskProvider diskProvider, IDetectApplicationType detectApplicationType, ITerminateNzbDrone terminateNzbDrone,
- IAppFolderInfo appFolderInfo, IBackupAndRestore backupAndRestore, IStartNzbDrone startNzbDrone, Logger logger)
+ public InstallUpdateService(IDiskProvider diskProvider,
+ IDetectApplicationType detectApplicationType,
+ ITerminateNzbDrone terminateNzbDrone,
+ IAppFolderInfo appFolderInfo,
+ IBackupAndRestore backupAndRestore,
+ IBackupAppData backupAppData,
+ IStartNzbDrone startNzbDrone,
+ Logger logger)
{
_diskProvider = diskProvider;
_detectApplicationType = detectApplicationType;
_terminateNzbDrone = terminateNzbDrone;
_appFolderInfo = appFolderInfo;
_backupAndRestore = backupAndRestore;
+ _backupAppData = backupAppData;
_startNzbDrone = startNzbDrone;
_logger = logger;
}
@@ -59,7 +67,8 @@ namespace NzbDrone.Update.UpdateEngine
{
_terminateNzbDrone.Terminate();
- _backupAndRestore.BackUp(installationFolder);
+ _backupAndRestore.Backup(installationFolder);
+ _backupAppData.Backup();
_logger.Info("Moving update package to target");