PortValhalla/scripts/Windows/OS/Manage.ps1

67 lines
2.2 KiB
PowerShell
Raw Normal View History

. "$PSScriptRoot/../Scripts/Context.ps1";
. "$PSScriptRoot/../Scripts/PersonalFiles.ps1";
. "$PSScriptRoot/../Software/git/Manage.ps1";
. "$PSScriptRoot/../Software/LGHub/Manage.ps1";
. "$PSScriptRoot/../Software/ManiaPlanet/Manage.ps1";
. "$PSScriptRoot/../Software/osu!/Manage.ps1";
. "$PSScriptRoot/../Software/osu!lazer/Manage.ps1";
. "$PSScriptRoot/../Software/PuTTY/Manage.ps1";
. "$PSScriptRoot/../Software/RetroArch/Manage.ps1";
. "$PSScriptRoot/../Software/reWASD/Manage.ps1";
. "$PSScriptRoot/../Software/TrackMania Nations Forever/Manage.ps1";
. "$PSScriptRoot/../Software/TrackMania United Forever/Manage.ps1";
. "$PSScriptRoot/../Software/VisualStudio/Manage.ps1";
function Invoke-WindowsBackup([Context] $context) {
2023-06-22 17:02:02 +00:00
Write-Information "Backing up Windows";
$backupRoot = $context.BackupRoot();
2023-06-09 17:05:08 +00:00
Invoke-FileBackup $context;
Invoke-BackupGit $context;
Invoke-BackupLGHub $context;
Invoke-BackupManiaPlanet $context;
Invoke-BackupOsu $context;
Invoke-BackupOsuLazer $context;
Invoke-BackupPuTTY $context;
Invoke-BackupRetroArch $context;
Invoke-BackupReWASD $context;
Invoke-BackupTmNations $context;
Invoke-BackupTmUnited $context;
Invoke-BackupVisualStudio $context;
$context.Backup($backupRoot, "$backupRoot.7z", @("-sdel"));
}
2023-06-16 18:24:22 +00:00
2023-06-16 18:30:53 +00:00
function Invoke-WindowsRestore([Context] $context) {
2023-06-22 17:02:02 +00:00
Write-Host "Restoring Windows";
2023-06-16 18:24:22 +00:00
function Read-Path()
{
$backupPath = Read-Host -Prompt "Please enter the path to the archive load the backup from.";
2023-06-22 16:36:29 +00:00
if ($backupPath -and (-not (Test-Path -PathType Leaf $backupPath)))
2023-06-16 18:24:22 +00:00
{
Write-Host "No file could be found at the specified path.";
return Read-Path;
}
2023-06-22 16:36:29 +00:00
else
{
return $backupPath;
}
2023-06-16 18:24:22 +00:00
}
2023-06-22 17:02:02 +00:00
Write-Information "Determining Backup Archive Path";
2023-06-16 18:24:22 +00:00
$backupPath = Read-Path;
$context = [Context]::new();
2023-06-16 18:30:53 +00:00
$context.BackupName ??= "PortValhalla";
$context.RootDir = $context.GetTempDirectory();
2023-06-18 18:11:49 +00:00
2023-06-22 16:40:01 +00:00
if ($backupPath)
2023-06-18 18:11:49 +00:00
{
$context.Restore($backupPath, $context.BackupRoot());
}
2023-06-22 16:44:31 +00:00
Invoke-FileRestore $context;
2023-06-22 18:44:40 +00:00
Invoke-RestoreGit $context;
2023-06-22 16:44:31 +00:00
Remove-Item -Recurse $context.RootDir;
2023-06-16 18:24:22 +00:00
}