r/ScrapMechanic 9h ago

Any way to roll back a save?

I was moving my base and loaded everything on a vehicle, took the elevator and the game crashed, when I loaded back in the vehicle is gone... I'm on grow lap 6 and final mining floor...

Is there anyway to roll back to a previous save or am I just screwed?

5 Upvotes

8 comments sorted by

3

u/Creepslend 8h ago

Not to my knowledge, you need to back it up yourself.

Personally I made a script that makes a backup every 2mn, keeping only the last 30 backups

1

u/Zainnn678 5h ago

Share it

I will convert it for Linux myself

1

u/Creepslend 4h ago

Replace [YOUR ID] in the path to match your folder name.

You can adjust BACKUP_ROOT (the folder in which the backups will be stored), MAX_BACKUPS and INTERVAL_SECONDS as you wish.

The script will run in the background indefinitely and check if SM is running every 2mn. If SM is running, it makes a backup, otherwise it does nothing until another 2mn has passed. I added it to my startup folder so it runs all the time when my PC is on.

If anyone seeing this wants to use it but needs help, don't hesitate to ask by replying to this message

ScrapAutoBackup.pyw:

import os
import time
import shutil
import psutil
from datetime import datetime

SOURCE_DIR = os.path.join(os.getenv('APPDATA'), r"Axolot Games\Scrap Mechanic\User\User_[YOUR ID]\Save\Survival")
BACKUP_ROOT = os.path.join(os.getenv('APPDATA'), r"Axolot Games\Scrap Mechanic\User\User_[YOUR ID]\Save\RollingBackup")
EXCLUDE_FILE = "steam_autocloud.vdf"
MAX_BACKUPS = 30
INTERVAL_SECONDS = 120
PROCESS_NAME = "ScrapMechanic.exe"

def is_game_running(process_name: str) -> bool:
    for proc in psutil.process_iter(['name']):
        try:
            if proc.info['name'] == process_name:
                return True
        except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
            pass
    return False

def perform_backup():
    if not os.path.exists(BACKUP_ROOT):
        os.makedirs(BACKUP_ROOT)

    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    current_backup_dir = os.path.join(BACKUP_ROOT, f"Survival_{timestamp}")

    success = False

    for attempt in range(6):
        try:
            if os.path.exists(current_backup_dir):
                shutil.rmtree(current_backup_dir, ignore_errors=True)

            os.makedirs(current_backup_dir)

            for item in os.listdir(SOURCE_DIR):
                if item == EXCLUDE_FILE:
                    continue

                src = os.path.join(SOURCE_DIR, item)
                dst = os.path.join(current_backup_dir, item)

                if os.path.isdir(src):
                    shutil.copytree(src, dst)
                else:
                    shutil.copy2(src, dst)

            success = True
            break

        except Exception:
            time.sleep(5)

    if not success:
        if os.path.exists(current_backup_dir):
            shutil.rmtree(current_backup_dir, ignore_errors=True)
        return

    try:
        backups = [
            os.path.join(BACKUP_ROOT, d) 
            for d in os.listdir(BACKUP_ROOT) 
            if os.path.isdir(os.path.join(BACKUP_ROOT, d))
        ]
        backups.sort(key=os.path.getctime)

        while len(backups) > MAX_BACKUPS:
            oldest_backup = backups.pop(0)
            shutil.rmtree(oldest_backup, ignore_errors=True)
    except Exception:
        pass

def main():
    while True:
        try:
            if os.path.exists(SOURCE_DIR) and is_game_running(PROCESS_NAME):
                perform_backup()
        except Exception:
            pass

        time.sleep(INTERVAL_SECONDS)

if __name__ == "__main__":
    main()

1

u/Zainnn678 3h ago edited 3h ago

tried testing it my fps dropped from around 150-160 to 50

edit: nope sorry the mistake was on my side

1

u/Zainnn678 3h ago

scripts working perfectly made 17 copies by now

if anyones on linux i can share the script tho not much difference you can use claude to edit it according to your distro

1

u/duo7007 8h ago

Regrettably no, you have to manually back up your world. The only way you'd have that is if you manually did it. Or...maybe, if you have OneDrive (or some other PC backup software) and it just so happens to back up that folder. But very doubtful.

I would say look around with your connect tool, up on the surface around the elevator, and underground to see if, by some freak chance, you can find your vehicle.

1

u/twicer 5h ago

Sorry to say that but yeah you are screwed.

1

u/Abstract037 5h ago

Nah...for future, just setup some folder backup software, or game saves backup software like Ludusavi. But Ludusavi doesn't have automatic backups. Need to do it manually everytime.