mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add backup/restore CLI options (not useful for most people)
This commit is contained in:
parent
565bc78161
commit
fd74b1b4dc
@ -32,7 +32,9 @@ namespace Wabbajack.CLI
|
|||||||
typeof(NoPatch),
|
typeof(NoPatch),
|
||||||
typeof(NexusPermissions),
|
typeof(NexusPermissions),
|
||||||
typeof(ExportServerGameFiles),
|
typeof(ExportServerGameFiles),
|
||||||
typeof(HashGamefiles)
|
typeof(HashGamefiles),
|
||||||
|
typeof(Backup),
|
||||||
|
typeof(Restore)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
97
Wabbajack.CLI/Verbs/Backup.cs
Normal file
97
Wabbajack.CLI/Verbs/Backup.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CommandLine;
|
||||||
|
using Wabbajack.Common;
|
||||||
|
using Wabbajack.Common.IO;
|
||||||
|
|
||||||
|
namespace Wabbajack.CLI.Verbs
|
||||||
|
{
|
||||||
|
|
||||||
|
[Verb("backup", HelpText = @"Copy all encrypted and personal info into a location for transferring to a new machine", Hidden = true)]
|
||||||
|
public class Backup : AVerb
|
||||||
|
{
|
||||||
|
public static Dictionary<string, bool> Keys = new Dictionary<string, bool>()
|
||||||
|
{
|
||||||
|
{"bunnycdn", true},
|
||||||
|
{"nexusapikey", true},
|
||||||
|
{"nexus-cookies", true},
|
||||||
|
{"x-metrics-key", true},
|
||||||
|
{"author-api-key.txt", false}
|
||||||
|
};
|
||||||
|
|
||||||
|
[Option('o', "output", Required = true, HelpText = @"Output folder for the decrypted data")]
|
||||||
|
public string Output { get; set; } = "";
|
||||||
|
|
||||||
|
public AbsolutePath OutputPath => (AbsolutePath)Output;
|
||||||
|
protected override async Task<ExitCode> Run()
|
||||||
|
{
|
||||||
|
foreach(var (name, encrypted) in Keys)
|
||||||
|
{
|
||||||
|
byte[] data;
|
||||||
|
var src = name.RelativeTo(Consts.LocalAppDataPath);
|
||||||
|
if (!src.Exists)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{name} doesn't exist, skipping");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encrypted)
|
||||||
|
{
|
||||||
|
data = await Utils.FromEncryptedData(name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = await src.ReadAllBytesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
await name.RelativeTo(OutputPath).WriteAllBytesAsync(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExitCode.Ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Verb("restore", HelpText = @"Copy all encrypted and personal info into a location for transferring to a new machine", Hidden = true)]
|
||||||
|
public class Restore : AVerb
|
||||||
|
{
|
||||||
|
public static Dictionary<string, bool> Keys = new Dictionary<string, bool>()
|
||||||
|
{
|
||||||
|
{"bunnycdn", true},
|
||||||
|
{"nexusapikey", true},
|
||||||
|
{"nexus-cookies", true},
|
||||||
|
{"x-metrics-key", true},
|
||||||
|
{"author-api-key.txt", false}
|
||||||
|
};
|
||||||
|
|
||||||
|
[Option('i', "input", Required = true, HelpText = @"Input folder for the decrypted data")]
|
||||||
|
public string Input { get; set; } = "";
|
||||||
|
|
||||||
|
public AbsolutePath InputPath => (AbsolutePath)Input;
|
||||||
|
protected override async Task<ExitCode> Run()
|
||||||
|
{
|
||||||
|
foreach(var (name, encrypted) in Keys)
|
||||||
|
{
|
||||||
|
var src = name.RelativeTo(InputPath);
|
||||||
|
if (!src.Exists)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{name} doesn't exist, skipping");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await src.ReadAllBytesAsync();
|
||||||
|
|
||||||
|
if (encrypted)
|
||||||
|
{
|
||||||
|
await data.ToEcryptedData(name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await name.RelativeTo(Consts.LocalAppDataPath).WriteAllBytesAsync(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExitCode.Ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user