PortValhalla/scripts/Windows/Scripts/PersonalFiles.ps1

41 lines
1.4 KiB
PowerShell
Raw Normal View History

2023-07-12 20:37:31 +00:00
#!/bin/pwsh
2024-08-07 19:05:32 +00:00
. "$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[]][]]@(
2024-03-23 16:18:38 +00:00
[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;
}
2023-06-30 10:19:54 +00:00
function Backup-PersonalFiles([Context] $context) {
2023-06-22 17:02:02 +00:00
Write-Host "Backing up Personal Files";
foreach ($candidate in Get-BackupCandidates) {
$context.Backup($candidate[1], $context.FileArchivePath($candidate[0]), $candidate[2]);
}
}
2023-06-22 16:44:31 +00:00
2023-06-30 10:19:54 +00:00
function Restore-PersonalFiles([Context] $context) {
2023-06-22 17:02:02 +00:00
Write-Host "Restoring Personal Files";
2023-06-22 16:44:31 +00:00
foreach ($candidate in Get-BackupCandidates) {
$archivePath = $context.FileArchivePath($candidate[0]);
$context.Restore($archivePath, $candidate[1]);
2023-06-22 16:44:31 +00:00
}
}