Results 1 to 2 of 2

Thread: Automatic Save Script

  1. #1
    Refugee
    Join Date
    May 2019
    Posts
    1
    Rep Power
    0

    Cool Automatic Save Script

    Hey guys !

    Recently I was hit by a second MD5 error so I decided to make sure my dedicated server creates some backup saves and so I don't loose hours of work for nothing.

    1. (optional) You will need to set up your Task scheduler to run a script if you are looking for automatic save, let's say every 20 minutes (minimum is 1m) or more or less, ass you want. I won't explain here how to use the task scheduler, you can google it.
    2. You need to create a new script.ps1 and copy/paste my script lines in it (you can use windows Powershell ISE), further instructions are directly in my script where you need to replace your save path(x) and backup path (y) etc..

    So here is the script :

    # This script saves your server files to a backup Folder
    #
    # (optional) You will need to program Task Scheduler to run this script every 20 min or more (minimum 1 min)
    #
    # Otherwise you can execute this script manually
    #
    # X (path) is the source folder with the name of your game/server,(found usually in C:/user/appdata/saves/Your Server)
    #
    # Y (path) is the destination folder where you want to save your backup (ex: external HDD/SSD)
    #
    # First You will need to change X and Y bellow by their actual paths
    #
    $source = X
    #
    $destination = Y
    #
    # Then we need to find the current Date & Time and create a folder named after it
    #
    $date = ((Get-Date).ToString('yyyy_MM_dd_hh_mm_ss'))
    New-Item -ItemType Directory -Path $destination -Name $date
    #
    # Now we want to save the server files in the folder we just created ($date)
    #
    Copy-Item -Path $source -Recurse -Destination $destination\$date -Force -Confirm:$false

    Enjoy !

    PS: If my script doesn't work you need to write this : ''Get-ExecutionPolicy''
    It should say Restricted (by default) then just type ''Set-ExecutionPolicy Unrestricted'' without the '' of course.

  2. #2
    Community Moderator SylenThunder's Avatar
    Join Date
    Oct 2014
    Location
    SE Michigan, out in the sticks.
    Posts
    8,040
    Rep Power
    1
    The problem you will run into on the Windows platform, is that copying the files while they are being used has a high chance of corrupting the data. It will almost always corrupt the copied version, and sometimes it will also corrupt the live version. This will cause problems in your world's region files, in the active player files, and in the main.ttw file most commonly. It can also corrupt the electricity and vehicles saved data as well, but those are less likely since they aren't used as much.

    Which is yet another reason why all my servers are on Linux.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •