Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A simple PowerShell script to backup Myth of Empires single player save file
- # Backups are stored in My Documents\MoEBackup
- # Twitter: @Kerbo_
- #
- ###################################################
- # Change this to your Steam path to MoE SaveGames #
- $moeDir = "N:\SteamLibrary\steamapps\common\Myth of Empires\WindowsPrivateServer\MOE\Saved\SaveGames"
- ###################################################
- $moeBackupDir = [Environment]::GetFolderPath("MyDocuments") + "\MoEBackup"
- $dateString = $(get-date -f yyy-MM-dd_HH-mm)
- # Create backup directory if it doesn't exist
- New-Item -ItemType Directory -Force -Path $moeBackupDir | Out-Null
- # Examine latest backup
- Push-Location $moeBackupDir
- $backup = gci SaveGames-* | select -last 1
- # New temp dir
- $parent = [System.IO.Path]::GetTempPath()
- [string] $name = [System.Guid]::NewGuid()
- $tempDir = New-Item -ItemType Directory -Path (Join-Path $parent $name)
- # Extract and get hash
- Expand-Archive -Path $backup -DestinationPath $tempDir
- $backup_hash = Get-FileHash $tempDir\World\LargeTerrain_Central_Main_100.sav
- # Remove temp dir
- Remove-Item -LiteralPath $tempDir -Force -Recurse
- Pop-Location
- Push-Location $moeDir
- $current_hash = Get-FileHash World\LargeTerrain_Central_Main_100.sav
- if ( $backup_hash.Hash -eq $current_hash.Hash ) {
- Write-Host "Save matches latest backup, no backup needed"
- } else {
- Write-Host "Backing up to $moeBackupDir\SaveGames-$dateString.zip"
- Compress-Archive -Path $moeDir\* -DestinationPath $moeBackupDir\SaveGames-$dateString.zip
- Write-Host "Done"
- }
- Pop-Location
- Start-Sleep -Seconds 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement