first commit
This commit is contained in:
36
Commands/ImportCommand.cs
Normal file
36
Commands/ImportCommand.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using HanaToolbox.Cli;
|
||||
using HanaToolbox.Config;
|
||||
using HanaToolbox.Logging;
|
||||
using HanaToolbox.Services;
|
||||
|
||||
namespace HanaToolbox.Commands;
|
||||
|
||||
public static class ImportCommand
|
||||
{
|
||||
public static async Task<int> RunAsync(CliArgs cli)
|
||||
{
|
||||
var log = new AppLogger(cli.Verbose);
|
||||
var schema = cli.Pos(0);
|
||||
var path = cli.Pos(1);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(schema) || string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
Console.Error.WriteLine("Usage: hanatoolbox import <schema> <path> [-c] [-t N] [--replace]");
|
||||
return 1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var config = ConfigService.Load();
|
||||
var sid = string.IsNullOrWhiteSpace(cli.Sid) ? config.Hana.Sid : cli.Sid;
|
||||
var svc = ServiceFactory.CreateBackupService(log);
|
||||
var locator = ServiceFactory.CreateLocator(log);
|
||||
var hdbsql = locator.LocateHdbsql(config.Hana.HdbsqlPath, sid, config.Hana.InstanceNumber);
|
||||
var threads = cli.Threads > 0 ? cli.Threads : Math.Max(1, Environment.ProcessorCount / 2);
|
||||
await svc.ImportSchemaAsync(hdbsql, config.Backup.UserKey, schema, path,
|
||||
threads, cli.Compress, cli.Replace, newSchema: null, sid, CancellationToken.None);
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex) { log.Error(ex.Message); return 1; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user