Mod Details

Event Auto Profile Backup

Event Auto Profile Backup 1.8.0

Created by  FriedEngineer

1.6K Downloads

SPT 3.11.4 Compatible

No more worries to backup your profile. Automatic event-based profile backup system with easy restore system.

Latest Version 1.8.0
SPT 3.11.4

Updated May 23, 5:03 AM

Version Notes

Update for 3.11

No functionality change.

Changes

  • Reduce default max backup files per profile to 20
  • Swap VFS for FileSystemSync (required by 3.11) and simplify FileSystem calls
  • Check for headless_ instead of dedicated_ profiles to ignore (required for 3.11 compatible Fika)
This download is externally hosted.
Always scan for viruses.
Features and Usage

Features

  • Automatically backup your profile when (Configurable)
    • Game Client Starts
    • Raid Starts
    • Raid Ends
    • Game Client Logs out
    • Whatever events you want! (ADVANCED ONLY. Basic Instructions in the Config tab)
  • Maximum Backup files Per Profile (Configurable)
  • Easy profile backup restoration

Usage

Creating backups

  • Do nothing! Once you install the mod it will automatically start making backups when the configured events occur.
  • Backups will be placed in user/profiles/EventAutoBackup/backups/profileUsername-profileID
  • Backup file format: Event-Timestamp.json
    (Example: 2025-01-14_21-14-49_OnGameStart.json)

Restoring Backups

  • Move or copy the backup file you wish to restore to user/profiles/EventAutoBackup/ProfilesToRestore folder and then restart the server.
  • When the restore is complete the file will be moved to user/profiles/EventAutoBackup/RestoredProfiles/.
  • user/profiles/EventAutoBackup/RestoredProfiles/ will retain a number of already restored files (Configurable)

Additional Details

  • Compatible with Fika
    • Creates separate backups for each profile
    • Does not back up dedicated/headless profiles as they would just take up space unnecessarily.
      • v1.7.0 (for 3.10) checks for dedicated_
      • v1.8.0 (for 3.11) checks for headless_
Installation

Extract zip and drop user folder inside of your SPTarkov folder

Demonstration Video (this is for SAIN, but the same concept applies to all of my mods). Credit to Drakia for the video

vKRw58b.gif

Config

For a bit of background, the “events” are triggered when the server receives a call to the specified route. You can enable, disable, and/or rename any of the events. Do not change the Route unless you know what you’re doing. (You should only have to rename them if SPT changes them in a future version).

The default config file includes helpful comments so I’ll start by just including it here. Any changes you make will take effect when the server is restarted.

// Set to false if you want to disable this mod entirely “Enabled”: true, // Write logs when a backup is saved “BackupSavedLog”: true, // Write logs when backups are deleted and the maximum number of backups per profile “MaximumBackupDeleteLog”: false, “MaximumBackupPerProfile”: 20, // Write logs when restored backups are deleted and the maximum number of restored backups “MaximumRestoredDeleteLog”: false, “MaximumRestoredFiles”: 10, // Which events should trigger a backup “AutoBackupEvents”: [ { “Enabled”: true, “Name”: “OnGameStart”, “Route”: “/client/game/start” }, { “Enabled”: true, “Name”: “OnRaidStart”, “Route”: “/client/match/local/start” }, { “Enabled”: true, “Name”: “OnRaidEnd”, “Route”: “/client/match/local/end” }, { “Enabled”: true, “Name”: “OnLogout”, “Route”: “/client/game/logout” } ] ### Advanced

By moving the routes into the config file I have also made it much easier to add additional events. If you are so inclined, here’s how I would recommend adding a new event

  1. Figure out the event on which you’d like to automatically create a profile backup.
  2. Figure out the route that corresponds to that event. The easiest way to do this is to perform the event and simultaneously watch the server logs to see which route was called.
  3. Add a new line with the event name and route to the list of AutoBackupEvents in the config.jsonc like so:

// Which events should trigger a backup “AutoBackupEvents”: [ { “Enabled”: true, “Name”: “OnGameStart”, “Route”: “/client/game/start” }, { “Enabled”: true, “Name”: “OnRaidStart”, “Route”: “/client/match/local/start” }, { “Enabled”: true, “Name”: “OnRaidEnd”, “Route”: “/client/match/local/end” }, { “Enabled”: true, “Name”: “OnLogout”, “Route”: “/client/game/logout” }, { “Enabled”: true, “Name”: “AnotherEvent”, “Route”: “/this/is/another/route” } ] A few words of caution:

  • I recommend that you do not add a route that occurs frequently.
    • I don’t really know the limit of how often often a backup be made before causing server performance issues from it constantly creating and probably deleting backup files.
    • I imagine that a significant number of profile backups of the same event would make it difficult to find the exact one you want.
  • I do not know if all routes will actually work. I have not tested any beyond the ones included by default so any you add are at your own risk
    • If you don’t want to venture into this on your own but you have an idea for an event to that you think should be included by default, please leave a comment on this hub page or open a Github issue here and I’ll see what I can do.
Changes

For 3.11 - v1.8.0

No functionality change.

Minor Changes

  • Reduce default max backup files per profile to 20
  • Swap VFS for FileSystemSync (required by 3.11) and simplify FileSystem calls
  • Check for headless_ instead of dedicated_ profiles to ignore (required for 3.11 compatible Fika)

For 3.10 - v1.7.0

Beyond the necessary changes for basic 3.10 compatibility, I made a few additional changes. Some were to more safely interact with base SPT, the SaveServer and BackupService in particular. The rest are largely based on my opinion or to suit my personal preference of how I envision is the best way use this mod. If you feel strongly about them, please leave a comment where I’d be happy to discuss them. There were a lot of under the hood changes, which you can see in the git history, but here are the high level changes

  • Enable Mod by default
    • I left the Enable/Disable config flag but it made no sense to me to have the mod disabled by default.
  • Renamed the mod to “EventAutoProfileBackup”
    • I think this more accurately reflects the function and more clearly communicates the difference between this and the SPT BackupService, which creates the user/profiles/backup/ folder for its backups
  • Backup file format: Was %Event%-%ISO Timeformat%.json. Now year-month-day_hour-minute-second_event.json
    • The timestamp portion now uses the format from the SPT Backup Service as I find it more human readable.
    • The timestamp now comes first in the name of file as I usually want to see the profile backups sorted by timestamp, not event, so I just put the timestamp first as that is how most filesystems will sort it.
  • Backup file directory
    • Was user/profiles/AutoBackup/sptVersion/profielId/. Now user/profiles/EventAutoBackup/backups/profileUsername-profileID/
    • I don’t think it’s necessary to include the SPT version here. It also means that old backup will not be deleted after you update to a new version of SPT. I think the new SPT Backup system handles this case better
    • I added the username in addition to the profileId so that it can be more easily identified if there are multiple profiles without opening the json and looking for the username (I imagine most people don’t memorize profileIds but would easily recognize a username)
  • Easy Profile Restore Process
    • Was copy to user/profiles. Now copy to user/profiles/EventAutoBackup/ProfilesToRestore/
    • Making it external was safer for the integrity of SPT services.
    • Copying to user/profiles and then modifying the files while SPT was running was in conflict with the BackupService and potentially the SaveServer.
  • Dynamically load endpoints from config
    • Allows anyone adventurous enough to add their own events without diving into the code itself
    • Cleaned up the code itself a bit by removing a lot of hard coded strings and duplicated code

Fixes:

  • Fixed an inherent incompatibility with running it in a Linux hosted environment.
  • No longer directly makes changes to the profile files for either backup or restore
    • It uses the SaveServer instead, which is the SPT service that is responsible for handling the profile data while the server is running and is responsible for writing the profile .json files.
    • This was change was strongly recommended by a few SPT and mod developers in the discord.
Credits

I’m obviously building heavily on the work of previous modders. They deserve credit for creating and maintaining this mod for so long.

Original Mod for SPT 3.1.x-3.2.5 by Lua: Lua’s Auto Profile Backup

Update for SPT 3.4-3.5 by Reis: (uploaded in the comments of Lua’s Auto Profile Backup)

Update for SPT 3.6-3.9 by Props : Lua’s Auto Profile Backup (Updated)

I also received some great help in the SPT discord from DrakiaXYZ, acidphantasm, and Jehree. Thank you!

Version 1.8.0
Download Mod Version
SPT 3.11.4
Latest Compatible SPT Version

878 Downloads

Created May 23, 5:03 AM

Updated May 23, 5:03 AM

Virus Total Results

Update for 3.11

No functionality change.

Changes

  • Reduce default max backup files per profile to 20
  • Swap VFS for FileSystemSync (required by 3.11) and simplify FileSystem calls
  • Check for headless_ instead of dedicated_ profiles to ignore (required for 3.11 compatible Fika)
Version 1.7.0
Download Mod Version
SPT 3.10.5
Latest Compatible SPT Version

760 Downloads

Created Jan 20, 7:43 PM

Updated Jan 20, 7:43 PM

Virus Total Results

Update for 3.10

sparrow8332

Dose this save character inventory on exfil ?

Looking for somthing to backup profile for when you exfil and its stuck and dosent go through back to main menu.

0 Likes

The default config has “OnRaidEnd”, which is triggered right before you get to the post-death screen (ie where we see “head, eyes”). So if you get to that screen, even if something happens before you make it back to your stash then yes, your profile would be backed up. If not, then you have deeper issues, probably with a local mods or with the connection to your server, which you should absolutely troubleshoot but this mod will not be able to workaround.

Background: When the exfil countdown completes it begins a handoff of the data from the client to the server. You know that the handoff is complete when you get to that first post-death screen. If that doesn’t get to that screen (your game client will likely just have the spinning circle in the bottom corner) then the handoff failed and there is no profile data for this mod to save anyways as it would grab it from the server’s memory.

0 Likes
RootsNine

I am running FIKA in a Docker container with Docker in Rootless mode, and attempting to restore backups from this mod completely breaks the container. The server fails to load and spits out “incorrect data check” errors, even after the file which I was attempting to restore is removed. The only fix I have found is to completely destroy and recreate the container.

0 Likes

I’m also running the SPT Server with Fika in a docker container (https://github.com/zhliau/fika-spt-server-docker on Debian 12 to be specific) and have never had issues restoring profiles. The only difference I can see is that I’m not running it in rootless mode. Can you shoot me your server logs?

0 Likes

The server itself wouldn’t ever start, the only logs the container would actually get to before restarting was this

Validating SPT version Validating Fika version Found server files, skipping init Fika install requested but Fika server mod dir already exists, skipping Fika installation Enabling profile backups Starting periodic command scheduler: cron. Checking running user/group: 0:1000 spt:x:1000: Changing permissions of server files to user+rwx, group+rwx, others+rx Error: incorrect data check at genericNodeError (node:internal/errors:983:15) at wrappedFn (node:internal/errors:537:14) at Zlib.zlibOnError [as onerror] (node:zlib:185:17) at processChunkSync (node:zlib:418:12) at zlibBufferSync (node:zlib:174:12) at syncBufferWrapper (node:zlib:769:14) at payloadFileSync (pkg/prelude/bootstrap.js:561:21) at Module._compile (pkg/prelude/bootstrap.js:1920:21) at Object..js (node:internal/modules/cjs/loader:1712:10) at Module.load (node:internal/modules/cjs/loader:1322:32) However, upon recreating the mounted volume and the container, placing the file into the ProfilesToRestore directory resulted in this error, and that error persisted after removing the file. This screamed permissions issue to me but everything was owned by the Rootless Docker user and group, 100999:100999
I am running this all on NixOS.
I’m going to be honest, I’m not sure who else to report this to if your mod is not at fault. This is literal weeks of me trying to solve this issue.

0 Likes

I agree, it does seem like a permissions issue, especially since it occurs right after the permissions change. I can’t think of why EventAutoProfileBackup would cause issues though as it uses SPT functions to interact with the file system.

The only thing I can think to try is setting the CHANGE_PERMISSIONS env variable to false so the code that produces Changing permissions of server files to user+rwx, group+rwx, others+rx doesn’t have the chance to run; I added it to the docker startup script last summer to handle other permissions issues but I never tried it in passwordless mode. If that doesn’t work, also try setting TAKE_OWNERSHIP, but since the take_ownership runs before the change_permissions, I’m less confident that’s the issue. If it doesn’t work with both of those set to false, I’ll have to dig quite a bit deeper.

Reference: https://github.com/zhliau/fika-spt-server-docker?tab=readme-ov-file#-environment-variables

0 Likes

I tried that, setting both of those to false still resulted in the error.

0 Likes

Hmmm. Unfortunately I don’t have any more ideas right now. I’m certainly not upset at you reporting it here, even if it ends up not being EventAutoProfileBackup at fault. Since you’ve reported that it only happens when using EventAutoProfileBackup to restore a profile backup, it is probably related. I’ll have to set up a rootless environment and get into the weeds to figure out what’s going on. If I’m being honest, I probably won’t have time to do that in the near future and maybe not even until I rewrite it for SPT 4.

You can do a “manual” restore by stopping the container, moving/copying the backup files to replace the profile file, and then starting the container again.

1 Like
Strungerman

Really great mod!! As a suggestion, i wonder if it is possible to save after a number of raids instead of after every one, since this creates too many backups and it makes it harder to know which one to restore. Thanks for the mod.

0 Likes

Thanks! I thought I’d replied to your comment weeks ago but it seems I did not. Sorry about that!

I put the timestamp at the beginning of the file name and the event at the end so that by just sorting by name you can see the files in chronological order and easily pick out the last time a given even occurred.

Implementing a system like what you’ve described is certainly possible in theory but I’d have to build out a system to keep track which would add a decent bit of complexity so I’m hesitant to do so. Right now it’s pretty simple as it just runs every time the events in the config file occur. The only obvious work-around that exists at the moment is to just disable some of the events in the config. For example if you only have it run a backup at game start then you’d only get about one backup per gaming session.

0 Likes

I didn’t notice the timestamps on the names of the files, that helps a lot thanks

1 Like
Spooks

This is awesome, thanks

1 Like
ODT

Thanks for updating it!

1 Like

Details