diff --git a/powershell/elden-ring-lp-backup.ps1 b/powershell/elden-ring-lp-backup.ps1 new file mode 100644 index 0000000..301cb86 --- /dev/null +++ b/powershell/elden-ring-lp-backup.ps1 @@ -0,0 +1,38 @@ +# This simple powershell script backups up my elden ring save to a remote git repository on my NAS +# by creating a commit and pushing it. +# After that, OBS, ER Death Counter as well as Elden Ring is started if not already running. + +$ER_SAVE_ID = "76561198077851234" +$OBS_PATH = "C:\Program Files\obs-studio\bin\64bit\obs64.exe" + + +function Open-If-Not-Already { + param ( + [Parameter(Mandatory = $true)] + [string]$Path, + [string]$ProcessName, + [string]$WorkingDirectory = (Get-Location).Path + ) + + if (-not $ProcessName) { + $ProcessName = (Get-Item $Path).BaseName + } + + if (-not (Get-Process -Name "$ProcessName" -ErrorAction SilentlyContinue)) { + Write-Output "Starting $ProcessName ($Path) ..." + Start-Process "$Path" -WorkingDirectory "$WorkingDirectory" + } + else { + Write-Output "$ProcessName is already running." + } +} + + +$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" + +git -C "${HOME}\AppData\Roaming\EldenRing\${ER_SAVE_ID}" commit --all --message "backup-${timestamp}" +git -C "${HOME}\AppData\Roaming\EldenRing\${ER_SAVE_ID}" push origin main + +Open-If-Not-Already -Path "C:\Program Files\obs-studio\bin\64bit\obs64.exe" -WorkingDirectory (Get-Item "$OBS_PATH").DirectoryName +Open-If-Not-Already -Path "C:\Program Files (x86)\ER Death Counter\ER_DeathCounter.exe" +Open-If-Not-Already -Path "steam://rungameid/1245620" -ProcessName "eldenring" \ No newline at end of file