Advertisement
kerbo_

SCUM-backup.ps1

Apr 22nd, 2022
1,715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # A simple PowerShell script to backup SCUM single player save file
  2. # Twitter: @Kerbo_
  3. #
  4. $scumDir = $env:LOCALAPPDATA + "\SCUM\Saved\SaveFiles"
  5. $dateString = $(get-date -f yyy-MM-dd_HH-mm)
  6. Push-Location $scumDir
  7.  
  8. $backup = gci SCUM-2* | select -last 1
  9. $backup_hash = Get-FileHash $backup
  10. $scumdb = Get-Item SCUM.db
  11. $scumdb_hash = Get-FileHash $scumdb
  12.  
  13. #Write-Host "$backup : $backup_hash"
  14. #Write-Host "$scumdb : $scumdb_hash"
  15.  
  16. if ( $backup_hash.Hash -eq $scumdb_hash.Hash ) {
  17.     Write-Host "SCUM.db matches latest backup, no backup needed" -ForegroundColor green
  18. } else {
  19.     cp SCUM.db SCUM-$dateString.db
  20.     $RET=$?
  21.     if ($RET) {
  22.         Write-Host "Copied SCUM.db to SCUM-$dateString.db" -ForegroundColor yellow
  23.     } else {
  24.         Write-Host "Error! cp returned $RET" -ForegroundColor red
  25.     }
  26. }
  27. Pop-Location
  28. Start-Sleep -Seconds 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement