diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..dcc0a313 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +backup/ \ No newline at end of file diff --git a/profiles/DerGeret/FileLists/Home.exclude.txt b/profiles/DerGeret/FileLists/Home.exclude.txt new file mode 100644 index 00000000..ac0b80aa --- /dev/null +++ b/profiles/DerGeret/FileLists/Home.exclude.txt @@ -0,0 +1,41 @@ +Pictures/Feedback +Documents/BeamNG.drive +Documents/Default.rdp +Documents/den4b/ReNamer +Documents/Dolphin Emulator +Documents/eFisc +Documents/Eigene* +Documents/Games +Documents/GitHub +Documents/IISExpress +Documents/KINGDOM HEARTS HD 1.5+2.5 ReMIX +Documents/ManiaPlanet +Documents/MetaX +Documents/MuseScore3 +Documents/My Games +Documents/My Web Sites +Documents/OneNote-Notizbücher +Documents/PCSX2 +Documents/PowerShell +Documents/PPSSPP +Documents/PS Vita +Documents/PSV Packages +Documents/PSV Updates +Documents/Rise of the Tomb Raider +Documents/S2 +Documents/SEGA +Documents/SEGA Mega Drive Classics +Documents/SQL Server Management Studio +Documents/Square Enix +Documents/TI-Nspire CX +Documents/TmForever +Documents/TrackMania +Documents/UltraVNC +Documents/Visual Studio 2017 +Documents/Visual Studio 2019 +Documents/Visual Studio 2022 +Documents/Viwizard M4V Converter +Documents/WindowsPowerShell +Documents/Zoom +Documents/reconnect.cmd +Music/iTunes diff --git a/profiles/DerGeret/FileLists/Home.include.txt b/profiles/DerGeret/FileLists/Home.include.txt new file mode 100644 index 00000000..3c8ed443 --- /dev/null +++ b/profiles/DerGeret/FileLists/Home.include.txt @@ -0,0 +1,5 @@ +Pictures +Documents +Downloads +Music +Videos diff --git a/profiles/DerGeret/FileLists/Public.exclude.txt b/profiles/DerGeret/FileLists/Public.exclude.txt new file mode 100644 index 00000000..bd557f2c --- /dev/null +++ b/profiles/DerGeret/FileLists/Public.exclude.txt @@ -0,0 +1,11 @@ +Documents/Hyper-V +Documents/reWASD/Logs +Documents/reWASD/Presets +Documents/reWASD/Profiles/Desktop +Documents/reWASD/Profiles/Duality +Documents/reWASD/Profiles/Fortnite +Documents/reWASD/Profiles/PS4 Remote* +Documents/reWASD/Profiles/Switch console +Documents/reWASD/Profiles/Switch to Xbox 360 +Documents/reWASD/Profiles/Valorant +Documents/reWASD/Profiles/xCloud diff --git a/profiles/DerGeret/FileLists/Public.include.txt b/profiles/DerGeret/FileLists/Public.include.txt new file mode 100644 index 00000000..27641ffe --- /dev/null +++ b/profiles/DerGeret/FileLists/Public.include.txt @@ -0,0 +1,5 @@ +Documents +Pictures +Downloads +Music +Videos diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 new file mode 100644 index 00000000..f24c346c --- /dev/null +++ b/scripts/Windows/Scripts/Context.ps1 @@ -0,0 +1,18 @@ +class Context { + [string]$BackupName; + [string] BackupRoot() { + return Join-Path $PSScriptRoot ".." ".." ".." "backup" $this.BackupName; + } + + [string] ArchivePath($name) { + return Join-Path $this.BackupRoot() "$name.7z"; + } + + [string] FileArchivePath($name) { + return $this.ArchivePath($(Join-Path "Files" $name)); + } + + [string] SoftwareArchive([string]$softwareName) { + return $this.ArchivePath($softwareName); + } +} diff --git a/scripts/Windows/Scripts/PersonalFiles.ps1 b/scripts/Windows/Scripts/PersonalFiles.ps1 new file mode 100644 index 00000000..3dd9d790 --- /dev/null +++ b/scripts/Windows/Scripts/PersonalFiles.ps1 @@ -0,0 +1,34 @@ +Import-Module "$PSScriptRoot/../../scripts/Common/Scripts/Context.ps1" -Force; + +function Get-BackupCandidates() { + [System.Collections.Generic.List[System.Tuple[string, string, string[]]]]$candidates = @(); + + $candidates.AddRange( + [System.Tuple[string, string, string[]][]]@( + [System.Tuple]::Create("Home", "$HOME", @("-i@`"$PSScriptRoot/FileLists/Home.include.txt`"", "-x@`"$PSScriptRoot/FileLists/Home.exclude.txt`"")), + [System.Tuple]::Create("Public", "$env:PUBLIC", @("-i@`"$PSScriptRoot/FileLists/Public.include.txt`"", "-x@`"$PSScriptRoot/FileLists/Public.exclude.txt`"")))); + + return $candidates; +} + +function Invoke-FileBackup([Context] $context) { + foreach ($candidate in Get-BackupCandidates) { + $archiveName = $context.FileArchivePath($candidate[0]); + + if (Test-Path $archiveName) { + Remove-Item -Recurse $archiveName; + } + + Start-Process -WorkingDirectory $candidate[1] ` + -ArgumentList ( + @( + "a", + "-xr!desktop.ini", + "-xr!{t,T}humbs.db") + + $candidate[2] + + @($archiveName)) ` + -FilePath "7z" ` + -NoNewWindow ` + -Wait; + } +}