1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2013-05-21 07:03:05 +03:00
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
2013-05-21 07:03:05 +03:00
namespace NzbDrone.Update.UpdateEngine
{
public interface IBackupAndRestore
{
void BackUp(string source);
void Restore(string target);
}
public class BackupAndRestore : IBackupAndRestore
{
private readonly IDiskProvider _diskProvider;
private readonly IAppFolderInfo _appFolderInfo;
2013-05-21 07:03:05 +03:00
private readonly Logger _logger;
public BackupAndRestore(IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, Logger logger)
2013-05-21 07:03:05 +03:00
{
_diskProvider = diskProvider;
_appFolderInfo = appFolderInfo;
2013-05-21 07:03:05 +03:00
_logger = logger;
}
public void BackUp(string source)
{
_logger.Info("Creating backup of existing installation");
_diskProvider.CopyFolder(source, _appFolderInfo.GetUpdateBackUpFolder());
2013-05-21 07:03:05 +03:00
}
public void Restore(string target)
{
_logger.Info("Attempting to rollback upgrade");
_diskProvider.CopyFolder(_appFolderInfo.GetUpdateBackUpFolder(), target);
2013-05-21 07:03:05 +03:00
}
}
}