From b3e3a84c1ebbbde6f9f2c2f23fa00565584b9f0f Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Wed, 28 Aug 2024 13:07:58 +0200
Subject: [PATCH] Allow backing up RetroArch

---
 scripts/Windows/Software/RetroArch/Manage.ps1 | 40 ++++++++++++++-----
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/scripts/Windows/Software/RetroArch/Manage.ps1 b/scripts/Windows/Software/RetroArch/Manage.ps1
index 578b6521..4838ed92 100644
--- a/scripts/Windows/Software/RetroArch/Manage.ps1
+++ b/scripts/Windows/Software/RetroArch/Manage.ps1
@@ -3,15 +3,33 @@ param(
     [hashtable] $Arguments
 )
 
-. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
-. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
+& {
+    param($Parameters)
+    . "$PSScriptRoot/../../Scripts/Restoration.ps1";
+    . "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
+    . "$PSScriptRoot/../../../Common/Scripts/System.ps1";
+    $path = "C:/tools/RetroArch-Win64";
 
-Start-SoftwareInstaller @PSBoundParameters `
-    -Installer {
-        Install-ChocoPackage retroarch;
-    } `
-    -Configurator {
-        Add-StartMenuIcon "RetroArch" "C:\tools\RetroArch-Win64\retroarch.exe";
-    };
-
-# ToDo: Add restoration
+    Start-SoftwareInstaller @Parameters `
+        -Backup {
+            Add-BackupArtifacts -Path "RetroArch" -Source $path `
+                -Include @(
+                    "config",
+                    "cores",
+                    "downloads",
+                    "playlists",
+                    "recordings",
+                    "screenshots",
+                    "content_history.lpl",
+                    "content_*_history.lpl",
+                    "retroarch.cfg"
+                );
+        } `
+        -Installer {
+            Install-ChocoPackage retroarch;
+        } `
+        -Configurator {
+            Add-StartMenuIcon "RetroArch" "C:\tools\RetroArch-Win64\retroarch.exe";
+            Expand-BackupArtifacts -Path "RetroArch" -Target $path;
+        };
+} $PSBoundParameters;