2012-01-27 05:05:09 +00:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-27 05:24:41 +00:00
|
|
|
|
var dbFile = _enviromentProvider.GetNzbDronoeDbFile();
|
|
|
|
|
var configFile = _enviromentProvider.GetConfigPath();
|
|
|
|
|
var zipFile = _enviromentProvider.GetConfigBackupFile();
|
2012-01-27 05:05:09 +00:00
|
|
|
|
|
2012-01-27 05:24:41 +00:00
|
|
|
|
using (var zip = new ZipFile())
|
2012-01-27 05:05:09 +00:00
|
|
|
|
{
|
2012-01-27 05:24:41 +00:00
|
|
|
|
zip.AddFile(dbFile, String.Empty);
|
|
|
|
|
zip.AddFile(configFile, String.Empty);
|
|
|
|
|
zip.Save(zipFile);
|
2012-01-27 05:05:09 +00:00
|
|
|
|
}
|
2012-01-27 05:24:41 +00:00
|
|
|
|
|
|
|
|
|
return zipFile;
|
2012-01-27 05:05:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|