Add scripts for backing up personal files
This commit is contained in:
parent
823f0dac5e
commit
d0eff6a264
7 changed files with 115 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
backup/
|
41
profiles/DerGeret/FileLists/Home.exclude.txt
Normal file
41
profiles/DerGeret/FileLists/Home.exclude.txt
Normal 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
|
5
profiles/DerGeret/FileLists/Home.include.txt
Normal file
5
profiles/DerGeret/FileLists/Home.include.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
Pictures
|
||||
Documents
|
||||
Downloads
|
||||
Music
|
||||
Videos
|
11
profiles/DerGeret/FileLists/Public.exclude.txt
Normal file
11
profiles/DerGeret/FileLists/Public.exclude.txt
Normal 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
|
5
profiles/DerGeret/FileLists/Public.include.txt
Normal file
5
profiles/DerGeret/FileLists/Public.include.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
Documents
|
||||
Pictures
|
||||
Downloads
|
||||
Music
|
||||
Videos
|
18
scripts/Windows/Scripts/Context.ps1
Normal file
18
scripts/Windows/Scripts/Context.ps1
Normal 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);
|
||||
}
|
||||
}
|
34
scripts/Windows/Scripts/PersonalFiles.ps1
Normal file
34
scripts/Windows/Scripts/PersonalFiles.ps1
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue