Add scripts for backing up personal files

This commit is contained in:
Manuel Thalmann 2023-06-07 00:56:29 +02:00
parent 823f0dac5e
commit d0eff6a264
7 changed files with 115 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
backup/

View file

@ -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

View file

@ -0,0 +1,5 @@
Pictures
Documents
Downloads
Music
Videos

View file

@ -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

View file

@ -0,0 +1,5 @@
Documents
Pictures
Downloads
Music
Videos

View file

@ -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);
}
}

View file

@ -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;
}
}