From c45a659aaa58ebfba26a2fe1e77970ab4bf56964 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 22 Jun 2023 18:44:31 +0200 Subject: [PATCH] Add scripts for restoring files --- scripts/Windows/OS/Manage.ps1 | 2 ++ scripts/Windows/Scripts/PersonalFiles.ps1 | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/scripts/Windows/OS/Manage.ps1 b/scripts/Windows/OS/Manage.ps1 index 589d35b3..80fe039e 100644 --- a/scripts/Windows/OS/Manage.ps1 +++ b/scripts/Windows/OS/Manage.ps1 @@ -55,5 +55,7 @@ function Invoke-WindowsRestore([Context] $context) { $context.Restore($backupPath, $context.BackupRoot()); } + Invoke-FileRestore $context; + Remove-Item -Recurse $context.RootDir; } diff --git a/scripts/Windows/Scripts/PersonalFiles.ps1 b/scripts/Windows/Scripts/PersonalFiles.ps1 index 02aa638f..97b14435 100644 --- a/scripts/Windows/Scripts/PersonalFiles.ps1 +++ b/scripts/Windows/Scripts/PersonalFiles.ps1 @@ -16,3 +16,13 @@ function Invoke-FileBackup([Context] $context) { $context.Backup($candidate[1], $context.FileArchivePath($candidate[0]), $candidate[2]); } } + +function Invoke-FileRestore([Context] $context) { + foreach ($candidate in Get-BackupCandidates) { + $archivePath = $context.FileArchivePath($candidate[0]); + + if (Test-Path -PathType Leaf $archivePath) { + $context.Restore($archivePath, $candidate[1]); + } + } +}