2023-07-12 20:37:31 +00:00
|
|
|
#!/bin/pwsh
|
2024-08-07 19:05:32 +00:00
|
|
|
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
|
2023-06-06 22:56:29 +00:00
|
|
|
|
|
|
|
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`""))));
|
2023-06-06 22:56:29 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
|
2023-06-06 22:56:29 +00:00
|
|
|
foreach ($candidate in Get-BackupCandidates) {
|
2023-06-06 23:32:14 +00:00
|
|
|
$context.Backup($candidate[1], $context.FileArchivePath($candidate[0]), $candidate[2]);
|
2023-06-06 22:56:29 +00:00
|
|
|
}
|
|
|
|
}
|
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]);
|
2023-08-05 01:03:47 +00:00
|
|
|
$context.Restore($archivePath, $candidate[1]);
|
2023-06-22 16:44:31 +00:00
|
|
|
}
|
|
|
|
}
|