PortValhalla/scripts/Windows/OS/Manage.ps1

59 lines
2 KiB
PowerShell

. "$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) {
$backupRoot = $context.BackupRoot();
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"));
}
function Invoke-WindowsRestore([Context] $context) {
function Read-Path()
{
$backupPath = Read-Host -Prompt "Please enter the path to the archive load the backup from.";
if (-not $backupPath -or (-not (Test-Path -PathType Leaf $backupPath)))
{
Write-Host "No file could be found at the specified path.";
return Read-Path;
}
}
$backupPath = Read-Path;
$context = [Context]::new();
$context.BackupName ??= "PortValhalla";
$context.RootDir = $context.GetTempDirectory();
if (-not $backupPath)
{
New-Item -ItemType Directory "$backupPath";
}
else
{
$context.Restore($backupPath, $context.BackupRoot());
}
Remove-Item -Recurse $context.RootDir;
}