PortValhalla/scripts/Windows/Scripts/Context.ps1

36 lines
1 KiB
PowerShell

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);
}
[void] Backup([string]$sourcePath, [string]$archivePath, [string[]]$arguments) {
if (Test-Path $archivePath) {
Remove-Item -Recurse $archivePath;
}
Start-Process -WorkingDirectory "$sourcePath" `
-FilePath "7z" `
-ArgumentList (
@(
"a",
"-xr!desktop.ini",
"-xr!thumbs.db",
"-xr!Thumbs.db",
$archivePath) + $arguments) `
-Wait `
-NoNewWindow;
}
}