commit
6cabbcb8b7
|
@ -17,6 +17,8 @@ namespace NzbDrone.Common
|
||||||
public const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
|
public const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
|
||||||
public const string LOG_DB_FILE = "log.sdf";
|
public const string LOG_DB_FILE = "log.sdf";
|
||||||
|
|
||||||
|
private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
|
||||||
|
|
||||||
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update\\";
|
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update\\";
|
||||||
private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\";
|
private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\";
|
||||||
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
|
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
|
||||||
|
@ -144,9 +146,15 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.txt");
|
return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetArchivedLogFileName(this EnviromentProvider enviromentProvider)
|
public static string GetArchivedLogFileName(this EnviromentProvider enviromentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.0.txt");
|
return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.0.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetConfigBackupFile(this EnviromentProvider enviromentProvider)
|
||||||
|
{
|
||||||
|
return Path.Combine(enviromentProvider.GetAppDataPath(), BACKUP_ZIP_FILE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,11 +12,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void Should_extract_to_correct_folder()
|
public void Should_extract_to_correct_folder()
|
||||||
{
|
{
|
||||||
var archiveProvider = new ArchiveProvider();
|
|
||||||
|
|
||||||
var destination = Path.Combine(TempFolder, "destination");
|
var destination = Path.Combine(TempFolder, "destination");
|
||||||
archiveProvider.ExtractArchive(GetTestFilePath("TestArchive.zip"), destination);
|
Mocker.Resolve<ArchiveProvider>().ExtractArchive(GetTestFilePath("TestArchive.zip"), destination);
|
||||||
|
|
||||||
|
|
||||||
var destinationFolder = new DirectoryInfo(destination);
|
var destinationFolder = new DirectoryInfo(destination);
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@
|
||||||
<Compile Include="Model\Xbmc\TvShowResult.cs" />
|
<Compile Include="Model\Xbmc\TvShowResult.cs" />
|
||||||
<Compile Include="Model\Xbmc\ErrorResult.cs" />
|
<Compile Include="Model\Xbmc\ErrorResult.cs" />
|
||||||
<Compile Include="Model\Xbmc\IconType.cs" />
|
<Compile Include="Model\Xbmc\IconType.cs" />
|
||||||
|
<Compile Include="Providers\BackupProvider.cs" />
|
||||||
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
|
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
|
||||||
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />
|
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />
|
||||||
<Compile Include="Providers\Indexer\Newznab.cs" />
|
<Compile Include="Providers\Indexer\Newznab.cs" />
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Ionic.Zip;
|
||||||
|
using NLog;
|
||||||
|
using Ninject;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Providers
|
||||||
|
{
|
||||||
|
public class BackupProvider
|
||||||
|
{
|
||||||
|
private readonly EnviromentProvider _enviromentProvider;
|
||||||
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public BackupProvider(EnviromentProvider enviromentProvider)
|
||||||
|
{
|
||||||
|
_enviromentProvider = enviromentProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BackupProvider()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string CreateBackupZip()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dbFile = _enviromentProvider.GetNzbDronoeDbFile();
|
||||||
|
var configFile = _enviromentProvider.GetConfigPath();
|
||||||
|
var zipFile = _enviromentProvider.GetConfigBackupFile();
|
||||||
|
|
||||||
|
using (var zip = new ZipFile())
|
||||||
|
{
|
||||||
|
zip.AddFile(dbFile, String.Empty);
|
||||||
|
zip.AddFile(configFile, String.Empty);
|
||||||
|
zip.Save(zipFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return zipFile;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.ErrorException("Failed to create backup zip", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,16 @@
|
||||||
using System.Linq;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Ionic.Zip;
|
using Ionic.Zip;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using Ninject;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Core
|
namespace NzbDrone.Core.Providers.Core
|
||||||
{
|
{
|
||||||
public class ArchiveProvider
|
public class ArchiveProvider
|
||||||
{
|
{
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
|
||||||
public virtual void ExtractArchive(string compressedFile, string destination)
|
public virtual void ExtractArchive(string compressedFile, string destination)
|
||||||
{
|
{
|
||||||
|
@ -20,6 +23,5 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
logger.Trace("Extraction complete.");
|
logger.Trace("Extraction complete.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,13 +19,17 @@ namespace NzbDrone.Web.Controllers
|
||||||
private readonly IndexerProvider _indexerProvider;
|
private readonly IndexerProvider _indexerProvider;
|
||||||
private readonly ConfigProvider _configProvider;
|
private readonly ConfigProvider _configProvider;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
|
private readonly BackupProvider _backupProvider;
|
||||||
|
|
||||||
public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider, ConfigProvider configProvider, DiskProvider diskProvider)
|
public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider,
|
||||||
|
ConfigProvider configProvider, DiskProvider diskProvider,
|
||||||
|
BackupProvider backupProvider)
|
||||||
{
|
{
|
||||||
_jobProvider = jobProvider;
|
_jobProvider = jobProvider;
|
||||||
_indexerProvider = indexerProvider;
|
_indexerProvider = indexerProvider;
|
||||||
_configProvider = configProvider;
|
_configProvider = configProvider;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
|
_backupProvider = backupProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Jobs()
|
public ActionResult Jobs()
|
||||||
|
@ -48,13 +52,11 @@ namespace NzbDrone.Web.Controllers
|
||||||
return View(_indexerProvider.All());
|
return View(_indexerProvider.All());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ActionResult Config()
|
public ActionResult Config()
|
||||||
{
|
{
|
||||||
return View(_configProvider.All());
|
return View(_configProvider.All());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[GridAction]
|
[GridAction]
|
||||||
public ActionResult _SelectAjaxEditing()
|
public ActionResult _SelectAjaxEditing()
|
||||||
{
|
{
|
||||||
|
@ -144,5 +146,13 @@ namespace NzbDrone.Web.Controllers
|
||||||
|
|
||||||
return JsonNotificationResult.Info("Job Queued");
|
return JsonNotificationResult.Info("Job Queued");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Backup()
|
||||||
|
{
|
||||||
|
var file = _backupProvider.CreateBackupZip();
|
||||||
|
var fileInfo = new FileInfo(file);
|
||||||
|
|
||||||
|
return File(fileInfo.FullName, "application/binary", fileInfo.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
<span class="small">@Html.DescriptionFor(m => m.AuthenticationType)</span>
|
<span class="small">@Html.DescriptionFor(m => m.AuthenticationType)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.DropDownListFor(m => m.AuthenticationType, Model.AuthTypeSelectList, new { @class = "inputClass" })
|
@Html.DropDownListFor(m => m.AuthenticationType, Model.AuthTypeSelectList, new { @class = "inputClass" })
|
||||||
|
|
||||||
|
<label class="labelClass"> Backup Configuration
|
||||||
|
<span class="small">Backup your Configuration file and Database</span>
|
||||||
|
</label>
|
||||||
|
<input type="button" value="Backup Now" onclick="window.location='../System/Backup'; return false;" class="inputClass" />
|
||||||
|
|
||||||
<button type="submit" class="save_button" disabled="disabled">
|
<button type="submit" class="save_button" disabled="disabled">
|
||||||
Save</button>
|
Save</button>
|
||||||
|
|
Loading…
Reference in New Issue