2023-07-12 20:37:31 +00:00
|
|
|
#!/bin/pwsh
|
2023-06-08 00:29:22 +00:00
|
|
|
. "$PSScriptRoot/../Scripts/PersonalFiles.ps1";
|
2023-07-16 11:12:47 +00:00
|
|
|
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
2024-08-07 21:45:56 +00:00
|
|
|
. "$PSScriptRoot/../Software/Nextcloud/Install.ps1";
|
2023-06-30 10:24:12 +00:00
|
|
|
. "$PSScriptRoot/../Collections/Personal.ps1";
|
2024-08-07 19:05:32 +00:00
|
|
|
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
|
2023-06-08 00:29:22 +00:00
|
|
|
|
2023-06-30 10:19:54 +00:00
|
|
|
function Backup-WindowsInstallation([Context] $context) {
|
2023-06-22 17:02:02 +00:00
|
|
|
Write-Information "Backing up Windows";
|
2024-03-23 16:32:45 +00:00
|
|
|
$Global:InformationPreference = "Continue";
|
|
|
|
$Global:ErrorActionPreference = "Inquire";
|
2024-03-23 14:16:12 +00:00
|
|
|
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
|
2023-06-08 00:29:22 +00:00
|
|
|
$backupRoot = $context.BackupRoot();
|
2023-06-30 10:19:54 +00:00
|
|
|
Backup-PersonalFiles $context;
|
2023-06-30 10:24:12 +00:00
|
|
|
Backup-PersonalApps $context;
|
2023-08-02 10:56:40 +00:00
|
|
|
$context.Backup($backupRoot, "$backupRoot.7z", @("-sdel"), $false);
|
2023-07-29 19:16:42 +00:00
|
|
|
$context.Cleanup();
|
2024-03-23 15:34:08 +00:00
|
|
|
Write-Host "Never forget to store the backup somewhere safe!";
|
|
|
|
Write-Host "I mean... what kind of a dumbass would ever forget to do so, right?";
|
2023-06-08 00:29:22 +00:00
|
|
|
}
|
2023-06-16 18:24:22 +00:00
|
|
|
|
2023-06-30 10:19:54 +00:00
|
|
|
function Restore-WindowsInstallation([Context] $context) {
|
2023-06-22 17:02:02 +00:00
|
|
|
Write-Host "Restoring Windows";
|
2023-07-12 23:30:27 +00:00
|
|
|
choco feature enable -n useEnhancedExitCodes;
|
2023-06-22 17:02:02 +00:00
|
|
|
|
2023-06-16 18:24:22 +00:00
|
|
|
function Read-Path()
|
|
|
|
{
|
2023-07-29 09:07:52 +00:00
|
|
|
$backupPath = Read-Host -Prompt "Please enter the path to the archive to load the backup from.";
|
2023-06-16 18:24:22 +00:00
|
|
|
|
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-07-16 10:39:07 +00:00
|
|
|
Install-Firefox $context;
|
2023-07-12 16:05:38 +00:00
|
|
|
Restore-Nextcloud $context;
|
|
|
|
|
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;
|
2023-06-16 18:30:53 +00:00
|
|
|
$context.BackupName ??= "PortValhalla";
|
2023-06-16 18:27:07 +00:00
|
|
|
$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-08-05 02:11:43 +00:00
|
|
|
Copy-UserInternationalSettingsToSystem -WelcomeScreen $True -NewUser $False;
|
2023-06-30 10:19:54 +00:00
|
|
|
Restore-PersonalFiles $context;
|
2023-09-27 10:32:27 +00:00
|
|
|
|
|
|
|
if ((Get-Command Restore-Apps -ErrorAction SilentlyContinue)) {
|
|
|
|
Restore-Apps $context;
|
|
|
|
}
|
|
|
|
|
2023-06-16 18:27:07 +00:00
|
|
|
Remove-Item -Recurse $context.RootDir;
|
2023-07-03 11:24:36 +00:00
|
|
|
$context.Cleanup();
|
2023-06-16 18:24:22 +00:00
|
|
|
}
|