Ignore unspecified backup archives
This commit is contained in:
parent
4c11809c49
commit
1c3a2fe2e7
|
@ -76,47 +76,49 @@ $null = New-Module {
|
|||
[string[]] $Exclude
|
||||
)
|
||||
|
||||
[List[string]] $argumentList = @();
|
||||
$dir = New-TemporaryDirectory;
|
||||
$targetPath = & $pathResolver @PSBoundParameters;
|
||||
$fullPath = Join-Path $dir $targetPath;
|
||||
$null = New-Item -ItemType Directory -Force (Split-Path -Parent $fullPath);
|
||||
if ($env:BACKUP_ARCHIVE) {
|
||||
[List[string]] $argumentList = @();
|
||||
$dir = New-TemporaryDirectory;
|
||||
$targetPath = & $pathResolver @PSBoundParameters;
|
||||
$fullPath = Join-Path $dir $targetPath;
|
||||
$null = New-Item -ItemType Directory -Force (Split-Path -Parent $fullPath);
|
||||
|
||||
if (Test-Path -PathType Container $Source) {
|
||||
$null = New-Item -ItemType Junction $fullPath -Target $Source;
|
||||
} elseif (Test-Path -PathType Leaf $Source) {
|
||||
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)`"");
|
||||
if (Test-Path -PathType Container $Source) {
|
||||
$null = New-Item -ItemType Junction $fullPath -Target $Source;
|
||||
} elseif (Test-Path -PathType Leaf $Source) {
|
||||
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)`"");
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
$dir = New-TemporaryDirectory;
|
||||
$sourcePath = & $pathResolver @PSBoundParameters;
|
||||
$filePath = Join-Path $dir $sourcePath;
|
||||
7z x "-o$dir" (Get-ValhallaBackupArchive) $sourcePath @ArgumentList;
|
||||
if ($env:BACKUP_ARCHIVE) {
|
||||
$dir = New-TemporaryDirectory;
|
||||
$sourcePath = & $pathResolver @PSBoundParameters;
|
||||
$filePath = Join-Path $dir $sourcePath;
|
||||
7z x "-o$dir" (Get-ValhallaBackupArchive) $sourcePath @ArgumentList;
|
||||
|
||||
if (Test-Path $filePath) {
|
||||
Copy-Item -Recurse (Join-Path $dir $sourcePath) $Target;
|
||||
if (Test-Path $filePath) {
|
||||
Copy-Item -Recurse (Join-Path $dir $sourcePath) $Target;
|
||||
}
|
||||
|
||||
Remove-Item -Recurse -Force $dir;
|
||||
}
|
||||
|
||||
Remove-Item -Recurse -Force $dir;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue