Event Auto Profile Backup 1.7.0
-
- SPT 3.10
- FriedEngineer
- 80 Downloads
- 1 Comment
Bothering mod authors will lead to warnings and repeat offenses will lead to eventual bans.
Formerly Lua-AutoProfileBackup. Updated for 3.10 with some additional changes.
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
Installation
Extract zip and drop user folder inside of your SPTarkov folder
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 profiles (those that start with dedicated_) as it would just take up space unnecessarily.
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": 50,
// 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" }
]
Display More
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
- Figure out the event on which you'd like to automatically create a profile backup.
- 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.
- 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.
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.
I'm obviously building heavily on the work of previous modders. So credit where credit is due:
Original Mod 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 discord from DrakiaXYZ, acidphantasm, Jehree
-
Version 1.7.0
- FriedEngineer
- 80 Downloads
ODT
Thanks for updating it!