mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Cleaned up Backup.
This commit is contained in:
parent
928bc55839
commit
8ce6e8a08e
5 changed files with 69 additions and 41 deletions
53
NzbDrone.Core/Providers/BackupProvider.cs
Normal file
53
NzbDrone.Core/Providers/BackupProvider.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue