diff --git a/Endpoints/BackupEndpoint.cs b/Endpoints/BackupEndpoint.cs index f5b8f15..dd257e4 100644 --- a/Endpoints/BackupEndpoint.cs +++ b/Endpoints/BackupEndpoint.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; @@ -28,13 +29,23 @@ public static class BackupEndpoint var archiveName = $"gott-{timestamp}.tar.gz"; 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 { FileName = "tar", - ArgumentList = { "-czf", archivePath, "--exclude=backup", "-C", dataDir, "." }, RedirectStandardError = true, 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)) {