Advertisement
kerbo_

WotH-backup.ps1

Aug 17th, 2022 (edited)
1,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # A simple PowerShell script to backup Way of the Hunter save file
  2. # Twitter: @Kerbo_
  3. #
  4. # Set your Steam ID
  5. # How to find your Steam ID https://www.google.com/search?q=what+is+my+steam+id
  6. # or look at the folder name here %localappdata%\WayOfTheHunter\Saved\SaveGames\Account_xxxxxxxxxxx
  7. # and xxxxxxxxxxx is your Steam ID
  8. $steamID = CHANGEME
  9.  
  10. # No changes needed below here
  11. Write-Host "Stable"
  12. $wothDir = $env:LOCALAPPDATA + "\WayOfTheHunter\Saved\SaveGames\Account_" + $steamID
  13. $dateString = $(get-date -f yyy-MM-dd_HH-mm)
  14. if (-Not (Test-Path -Path $wothDir)) {
  15.     Write-Host "Error! Save file location not found: $wothDir" -ForegroundColor red
  16.     Start-Sleep -Seconds 5
  17.     exit
  18. }
  19. Push-Location $wothDir
  20.  
  21. $backup = gci SaveData-2* | select -last 1
  22. $backup_hash = Get-FileHash $backup
  23. $wothSave = Get-Item SaveData.sav
  24. $wothSave_hash = Get-FileHash $wothSave
  25.  
  26. #Write-Host "$backup : $backup_hash"
  27. #Write-Host "$wothSave : $wothSave_hash"
  28.  
  29. if ( $backup_hash.Hash -eq $wothSave_hash.Hash ) {
  30.     Write-Host "SaveData.sav matches latest backup, no backup needed" -ForegroundColor green
  31. } else {
  32.     cp SaveData.sav SaveData-$dateString.sav
  33.     $RET=$?
  34.     if ($RET) {
  35.         Write-Host "Copied SaveData.sav to SaveData-$dateString.db" -ForegroundColor yellow
  36.     } else {
  37.         Write-Host "Error! cp returned $RET" -ForegroundColor red
  38.     }
  39. }
  40. Pop-Location
  41.  
  42. # Beta
  43. Write-Host "Beta"
  44. $wothDir = $env:LOCALAPPDATA + "\WayOfTheHunter\Saved\SaveGames\Account_" + $steamID + "_development"
  45. $dateString = $(get-date -f yyy-MM-dd_HH-mm)
  46. if (-Not (Test-Path -Path $wothDir)) {
  47.     Write-Host "Beta save folder not found, will not backup" -ForegroundColor green
  48.     Start-Sleep -Seconds 5
  49.     exit
  50. }    
  51. Push-Location $wothDir
  52.  
  53. $backup = gci SaveData-2* | select -last 1
  54. $backup_hash = Get-FileHash $backup
  55. $wothSave = Get-Item SaveData.sav
  56. $wothSave_hash = Get-FileHash $wothSave
  57.  
  58. #Write-Host "$backup : $backup_hash"
  59. #Write-Host "$wothSave : $wothSave_hash"
  60.  
  61. if ( $backup_hash.Hash -eq $wothSave_hash.Hash ) {
  62.     Write-Host "SaveData.sav matches latest backup, no backup needed" -ForegroundColor green
  63. } else {
  64.     cp SaveData.sav SaveData-$dateString.sav
  65.     $RET=$?
  66.     if ($RET) {
  67.         Write-Host "Copied SaveData.sav to SaveData-$dateString.db" -ForegroundColor yellow
  68.     } else {
  69.         Write-Host "Error! cp returned $RET" -ForegroundColor red
  70.     }
  71. }
  72. Pop-Location
  73. Start-Sleep -Seconds 5
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement