Backup: tar.gz ohne ./Root-Ordner – Einträge direkt auf oberster Ebene
This commit is contained in:
1 parent
71bb97be13
commit
190a0d0a8b
1 file changed
+12
-1
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
@@ -28,13 +29,23 @@ public static class BackupEndpoint
|
|||||||
var archiveName = $"gott-{timestamp}.tar.gz";
|
var archiveName = $"gott-{timestamp}.tar.gz";
|
||||||
var archivePath = Path.Combine(backupDir, archiveName);
|
var archivePath = Path.Combine(backupDir, archiveName);
|
||||||
|
|
||||||
|
var entries = Directory.GetFileSystemEntries(dataDir)
|
||||||
|
.Select(e => Path.GetFileName(e))
|
||||||
|
.Where(e => e != "backup")
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
var psi = new ProcessStartInfo
|
var psi = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "tar",
|
FileName = "tar",
|
||||||
ArgumentList = { "-czf", archivePath, "--exclude=backup", "-C", dataDir, "." },
|
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
UseShellExecute = false
|
UseShellExecute = false
|
||||||
};
|
};
|
||||||
|
psi.ArgumentList.Add("-czf");
|
||||||
|
psi.ArgumentList.Add(archivePath);
|
||||||
|
psi.ArgumentList.Add("-C");
|
||||||
|
psi.ArgumentList.Add(dataDir);
|
||||||
|
foreach (var entry in entries)
|
||||||
|
psi.ArgumentList.Add(entry);
|
||||||
|
|
||||||
using (var process = Process.Start(psi))
|
using (var process = Process.Start(psi))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user