Skip to content

Commit

Permalink
Fix check version
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Jun 20, 2020
1 parent e5d6b45 commit 922fcd1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 58 deletions.
96 changes: 45 additions & 51 deletions src/Corsinvest.ProxmoxVE.NodeProtect.Api/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,43 +72,39 @@ private static DateTime DirectoryToDate(string directory)
foreach (var (host, port) in ClientHelper.GetHostsAndPorts(hostsAndPort, 22, true, null))
{
// Execute a (SHELL) Command for download
using (var sshClient = new SshClient(host, port, username, password))
{
//create tar
sshClient.Connect();

var cmdCreateTarGz = $"tar -cvzPf {fileNameTarGz} {string.Join(" ", pathsToBackup)}";
var retCmd = sshClient.CreateCommand(cmdCreateTarGz).Execute();
if (debug)
{
@out.WriteLine($"Create file tar.gz: {cmdCreateTarGz}");
@out.WriteLine($"Result command: {retCmd}");
}

var fileToSave = Path.Combine(pathSave, $"{host}{FILE_NAME}");

// download
using (var sftp = new SftpClient(host, port, username, password))
using (var stream = File.OpenWrite(fileToSave))
{
sftp.Connect();
if (debug) { @out.WriteLine($"Download file tar.gz: {fileNameTarGz} to {fileToSave}"); }
sftp.DownloadFile(fileNameTarGz, stream);
sftp.Disconnect();
}

//delete tar
var cmdRmTarGz = $"rm {fileNameTarGz}";
retCmd = sshClient.CreateCommand(cmdRmTarGz).Execute();
if (debug)
{
@out.WriteLine($"Delete tar.gz: {cmdRmTarGz}");
@out.WriteLine($"Result command: {retCmd}");
}
sshClient.Disconnect();

@out.WriteLine($"Create config: {fileToSave}");
}
using var sshClient = new SshClient(host, port, username, password);
//create tar
sshClient.Connect();

var cmdCreateTarGz = $"tar -cvzPf {fileNameTarGz} {string.Join(" ", pathsToBackup)}";
var retCmd = sshClient.CreateCommand(cmdCreateTarGz).Execute();
if (debug)
{
@out.WriteLine($"Create file tar.gz: {cmdCreateTarGz}");
@out.WriteLine($"Result command: {retCmd}");
}

var fileToSave = Path.Combine(pathSave, $"{host}{FILE_NAME}");

// download
using var sftp = new SftpClient(host, port, username, password);
using var stream = File.OpenWrite(fileToSave);
sftp.Connect();
if (debug) { @out.WriteLine($"Download file tar.gz: {fileNameTarGz} to {fileToSave}"); }
sftp.DownloadFile(fileNameTarGz, stream);
sftp.Disconnect();

//delete tar
var cmdRmTarGz = $"rm {fileNameTarGz}";
retCmd = sshClient.CreateCommand(cmdRmTarGz).Execute();
if (debug)
{
@out.WriteLine($"Delete tar.gz: {cmdRmTarGz}");
@out.WriteLine($"Result command: {retCmd}");
}
sshClient.Disconnect();

@out.WriteLine($"Create config: {fileToSave}");
}

//keep
Expand Down Expand Up @@ -154,20 +150,18 @@ public static void Delete(string directoryBackupDateTime, TextWriter @out)
var fileName = FileNameLinuxTarGz(DirectoryToDate(fileTarGz));

//upload
using (var sftp = new SftpClient(host, port, username, password))
using (var stream = File.OpenRead(fileTarGz))
{
sftp.Connect();

if (debug)
{
@out.WriteLine($"Host: {host}:{port}");
@out.WriteLine($"File upload: {fileName}");
}

sftp.UploadFile(stream, fileName);
sftp.Disconnect();
}
using var sftp = new SftpClient(host, port, username, password);
using var stream = File.OpenRead(fileTarGz);
sftp.Connect();

if (debug)
{
@out.WriteLine($"Host: {host}:{port}");
@out.WriteLine($"File upload: {fileName}");
}

sftp.UploadFile(stream, fileName);
sftp.Disconnect();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Version>1.0.0</Version>
<Version>1.2.0</Version>
<Company>Corsinvest Srl</Company>
<Authors>Daniele Corsini</Authors>
<Copyright>Corsinvest Srl</Copyright>
Expand All @@ -29,7 +29,7 @@

<ItemGroup>
<!-- <ProjectReference Include="..\..\..\cv4pve-api-dotnet\src\Corsinvest.ProxmoxVE.Api.Extension\Corsinvest.ProxmoxVE.Api.Extension.csproj" /> -->
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Extension" Version="2.3.0" />
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Extension" Version="2.5.3" />

<PackageReference Include="SSH.NET" Version="2016.1.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>cv4pve-node-protect</AssemblyName>
<Company>Corsinvest Srl</Company>
Expand All @@ -20,9 +20,9 @@
<TrimmerRootAssembly Include="System.Net.WebClient" />

<!-- <ProjectReference Include="..\..\..\cv4pve-api-dotnet\src\Corsinvest.ProxmoxVE.Api.Shell\Corsinvest.ProxmoxVE.Api.Shell.csproj" /> -->
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="2.3.0" />
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="2.5.3" />

<!-- <ProjectReference Include="..\Corsinvest.ProxmoxVE.NodeProtect.Api\Corsinvest.ProxmoxVE.NodeProtect.Api.csproj" /> -->
<PackageReference Include="Corsinvest.ProxmoxVE.NodeProtect.Api" Version="1.0.0" />
<PackageReference Include="Corsinvest.ProxmoxVE.NodeProtect.Api" Version="1.2.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Corsinvest.ProxmoxVE.NodeProtect/build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is part of the cv4pve-autosnap https://github.com/Corsinvest/cv4pve-pepper,
# This file is part of the cv4pve-node-protect https://github.com/Corsinvest/cv4pve-node-protect,
#
# This source file is available under two different licenses:
# - GNU General Public License version 3 (GPLv3)
Expand Down

0 comments on commit 922fcd1

Please sign in to comment.