Ignore unspecified backup archives
This commit is contained in:
parent
4c11809c49
commit
1c3a2fe2e7
1 changed files with 50 additions and 46 deletions
|
@ -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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue