Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A simple PowerShell script to backup RUN 8 configs
- # Twitter: @Kerbo_
- #
- # Change to your Run 8 path if not default
- $run8Dir = "C:\Run8Studios\Run8 Train Simulator V3"
- #
- # No changes below here
- #
- $ErrorActionPreference = 'SilentlyContinue'
- $dateString = $(get-date -f yyy-MM-dd_HH-mm)
- Push-Location $run8Dir
- $configs = @(
- "Content\RailDriverCalibration.r8"
- "Content\Run8KeySettings.r8"
- "Content\Run8Settings.r8"
- "Content\V3RailVehicles\HornBellConfiguration.r8"
- "Content\V3RailVehicles\UnitNumberDatabase.xml"
- )
- $regionFiles = @(
- "TrainSymbolRoutings.xml"
- "Config.ind"
- "Hump.r8"
- "Traffic.r8"
- "WX_Stations.txt"
- )
- foreach ($config in $configs) {
- $found = ""
- try {
- if(Test-Path -Path $config -PathType Leaf) {
- $found = "True"
- }
- } catch {
- # do nothing
- }
- if($found) {
- $config_hash = Get-FileHash $config
- $backup = gci $config-* | select -last 1
- $backup_hash = Get-FileHash $backup -EV Err -EA SilentlyContinue
- if ( $backup_hash.Hash -eq $config_hash.Hash ) {
- Write-Host "$config matches latest backup, no backup needed"
- } else {
- cp $config $config-$dateString
- $RET=$?
- if ($RET) {
- Write-Host "Copied $config to $config-$dateString"
- } else {
- Write-Host "Error! cp returned $RET for $config"
- }
- }
- }
- }
- foreach ($regionFile in $regionFiles) {
- $regionFilesFound = gci -Recurse $regionFile
- if ( $regionFilesFound ) {
- foreach ($config in $regionFilesFound) {
- $config_hash = Get-FileHash $config
- $backup = gci $config-* | select -last 1
- $backup_hash = Get-FileHash $backup -EV Err -EA SilentlyContinue
- if ( $backup_hash.Hash -eq $config_hash.Hash ) {
- Write-Host "$config matches latest backup, no backup needed"
- } else {
- cp $config $config-$dateString
- $RET=$?
- if ($RET) {
- Write-Host "Copied $config to $config-$dateString"
- } else {
- Write-Host "Error! cp returned $RET for $config"
- }
- }
- }
- }
- }
- Pop-Location
- # Sleep to show screen output before exiting
- Start-Sleep -Seconds 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement