Ignore unspecified backup archives

This commit is contained in:
Manuel Thalmann 2024-08-28 00:22:38 +02:00
parent 01791b293c
commit 66779b42cc

View file

@ -76,47 +76,49 @@ $null = New-Module {
[string[]] $Exclude [string[]] $Exclude
) )
[List[string]] $argumentList = @(); if ($env:BACKUP_ARCHIVE) {
$dir = New-TemporaryDirectory; [List[string]] $argumentList = @();
$targetPath = & $pathResolver @PSBoundParameters; $dir = New-TemporaryDirectory;
$fullPath = Join-Path $dir $targetPath; $targetPath = & $pathResolver @PSBoundParameters;
$null = New-Item -ItemType Directory -Force (Split-Path -Parent $fullPath); $fullPath = Join-Path $dir $targetPath;
$null = New-Item -ItemType Directory -Force (Split-Path -Parent $fullPath);
if (Test-Path -PathType Container $Source) { if (Test-Path -PathType Container $Source) {
$null = New-Item -ItemType Junction $fullPath -Target $Source; $null = New-Item -ItemType Junction $fullPath -Target $Source;
} elseif (Test-Path -PathType Leaf $Source) { } elseif (Test-Path -PathType Leaf $Source) {
Copy-Item $Source $fullPath; Copy-Item $Source $fullPath;
}
$options = @(
@("i", $Include),
@("x", $Exclude)
);
foreach ($option in $options) {
$indicator = $option[0];
$list = $option[1];
foreach ($pattern in $list) {
$argumentList.Add("-$indicator!`"$(Join-Path $targetPath $pattern)`"");
} }
$options = @(
@("i", $Include),
@("x", $Exclude)
);
foreach ($option in $options) {
$indicator = $option[0];
$list = $option[1];
foreach ($pattern in $list) {
$argumentList.Add("-$indicator!`"$(Join-Path $targetPath $pattern)`"");
}
}
Start-Process `
-NoNewWindow `
-Wait `
-WorkingDirectory $dir `
-FilePath 7z `
-ArgumentList (
@(
"a",
(Get-ValhallaBackupArchive),
"-xr!desktop.ini",
"-xr!thumbs.db",
"-xr!Thumbs.db"
) + $argumentList);
Remove-Item -Recurse -Force $dir;
} }
Start-Process `
-NoNewWindow `
-Wait `
-WorkingDirectory $dir `
-FilePath 7z `
-ArgumentList (
@(
"a",
(Get-ValhallaBackupArchive),
"-xr!desktop.ini",
"-xr!thumbs.db",
"-xr!Thumbs.db"
) + $argumentList);
Remove-Item -Recurse -Force $dir;
} }
<# <#
@ -144,15 +146,17 @@ $null = New-Module {
[string[]] $ArgumentList [string[]] $ArgumentList
) )
$dir = New-TemporaryDirectory; if ($env:BACKUP_ARCHIVE) {
$sourcePath = & $pathResolver @PSBoundParameters; $dir = New-TemporaryDirectory;
$filePath = Join-Path $dir $sourcePath; $sourcePath = & $pathResolver @PSBoundParameters;
7z x "-o$dir" (Get-ValhallaBackupArchive) $sourcePath @ArgumentList; $filePath = Join-Path $dir $sourcePath;
7z x "-o$dir" (Get-ValhallaBackupArchive) $sourcePath @ArgumentList;
if (Test-Path $filePath) { if (Test-Path $filePath) {
Copy-Item -Recurse (Join-Path $dir $sourcePath) $Target; Copy-Item -Recurse (Join-Path $dir $sourcePath) $Target;
}
Remove-Item -Recurse -Force $dir;
} }
Remove-Item -Recurse -Force $dir;
} }
}; };