PortValhalla/scripts/Windows/Scripts/PersonalFiles.ps1

35 lines
1.2 KiB
PowerShell
Raw Normal View History

Import-Module "$PSScriptRoot/../../scripts/Common/Scripts/Context.ps1" -Force;
function Get-BackupCandidates() {
[System.Collections.Generic.List[System.Tuple[string, string, string[]]]]$candidates = @();
$candidates.AddRange(
[System.Tuple[string, string, string[]][]]@(
[System.Tuple]::Create("Home", "$HOME", @("-i@`"$PSScriptRoot/FileLists/Home.include.txt`"", "-x@`"$PSScriptRoot/FileLists/Home.exclude.txt`"")),
[System.Tuple]::Create("Public", "$env:PUBLIC", @("-i@`"$PSScriptRoot/FileLists/Public.include.txt`"", "-x@`"$PSScriptRoot/FileLists/Public.exclude.txt`""))));
return $candidates;
}
function Invoke-FileBackup([Context] $context) {
foreach ($candidate in Get-BackupCandidates) {
$archiveName = $context.FileArchivePath($candidate[0]);
if (Test-Path $archiveName) {
Remove-Item -Recurse $archiveName;
}
Start-Process -WorkingDirectory $candidate[1] `
-ArgumentList (
@(
"a",
"-xr!desktop.ini",
"-xr!{t,T}humbs.db") +
$candidate[2] +
@($archiveName)) `
-FilePath "7z" `
-NoNewWindow `
-Wait;
}
}