PortValhalla/scripts/Windows/Scripts/PersonalFiles.ps1

41 lines
1.4 KiB
PowerShell

#!/bin/pwsh
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
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/../Resources/FileLists/Home.include.txt`"",
"-x@`"$PSScriptRoot/../Resources/FileLists/Home.exclude.txt`"")),
[System.Tuple]::Create(
"Public",
"$env:PUBLIC",
@(
"-i@`"$PSScriptRoot/../Resources/FileLists/Public.include.txt`"",
"-x@`"$PSScriptRoot/../Resources/FileLists/Public.exclude.txt`""))));
return $candidates;
}
function Backup-PersonalFiles([Context] $context) {
Write-Host "Backing up Personal Files";
foreach ($candidate in Get-BackupCandidates) {
$context.Backup($candidate[1], $context.FileArchivePath($candidate[0]), $candidate[2]);
}
}
function Restore-PersonalFiles([Context] $context) {
Write-Host "Restoring Personal Files";
foreach ($candidate in Get-BackupCandidates) {
$archivePath = $context.FileArchivePath($candidate[0]);
$context.Restore($archivePath, $candidate[1]);
}
}