• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Backup Mod [V1.1]

ntaklive

New member
image.png

Backup Mod
by ntaklive

Description
This modlet makes it possible to automatically backup and restore your game saves.

Settings

You can configure the modlet by modifying the 'settings.json' file, or you can also use the FilUnderscore's Mod Manager.
If you changed the configuration when you were in game, you should re-enter to your world to apply changed settings.

Code:
{
  "General": {
    // Backups limit
    // Default: 10
    "BackupsLimit": 10,
    
    // Custom backups folder path
    // IMPORTANT: You must escape all '\' characters or use '/'
    // Example: "C:\\7DaysToDie\\Backups"
    // Default: ""
    "CustomBackupsFolder": "",
    
    // Write debug information to the logs/log.txt file and to the in-game/server console
    // Default: false
    "DebugMode": false
  },
  
  "AutoBackup": {
    // Is automatic backup enabled
    // Default: true
    "Enabled": true,
    
    // Auto backup delay (seconds)
    // Min: 10
    // Default: 1200 (20 minutes)
    "Delay": 1200,
    
    // Reset the delay timer after a manual backup
    // Default: false
    "ResetDelayTimerAfterManualBackup": false,

    // Skip the next scheduled backup, if there are no players on the server
    // Default: false
    "SkipIfThereAreNoPlayers": false
  },
  
  "Archive": {
    // Keep the last backup of the day
    // Default: false
    "Enabled": false,

    // Backups limit
    // Default: 10
    "BackupsLimit": 10,
    
    // Custom archive folder path.
    // IMPORTANT: You must escape all '\' characters or use '/'
    // Example: "C:\\7DaysToDie\\Archive".
    // Default: ""
    "CustomArchiveFolder": ""
  },
  
  "Events": {
    // Backup when world loaded
    // Default: true
    "BackupOnWorldLoaded": true,

    // Backup when the last player on the server disconnected
    // Default: false
    "BackupOnServerIsEmpty": false
  },
  
  "Notifications": {
    // Are ALL chat notifications enabled
    // Default: true
    "Enabled": true,

    "Countdown" : {
      // Are countdown chat notifications enabled
      // Default: true
      "Enabled": true,
      
      // Do a countdown * seconds before backup starts
      // Min: 1
      // Default: 5
      "CountFrom": 5
    }
  }
}
By default, your backups for each save will be saved in the '%AppData%/Roaming/7DaysToDie/Backups/%WorldName%/%SaveName%' directory (on windows).
and your archived backups for each save will be saved in the '%AppData%/Roaming/7DaysToDie/Archive/%WorldName%/%SaveName%' folder (on windows).


P.S. You can also change the UserGameData property in your serverconfig.xml or in the game startup arguments. Then by default it will use the next directories: '%UserGameData%/Backups/%WorldName%/%SaveName%' for backups, and
'%UserGameData%/Archive/%WorldName%/%SaveName%' for archive


Commands

You can use the 'backup' command or its shortened version - the 'bp' command

'backup' - perform a forceful backup
'backup info' - show the current configuration of the mod
'backup list' - show all available backups
'backup restore' - restore a save from a backup
'backup delete' - delete a backup
'backup start' - start an AutoBackup process (even if disabled in settings.json)
'backup stop' - stop the current AutoBackup process


Installation
1. Extract the downloaded .zip archive
2. Move the extracted 'BackupMod' folder into your 'Mods' folder


Compatibility
Required game version: V1.1+

EAC Compatibility
Server only. To load in single-player mode, you must disable EAC.

Download
GitHub

Support
Coin: USDT
Network: BSC - BNB Smart Chain (BEP20)
Address: 0xb7a5bf6e55739aaf848a0a54161a45e9b580a5a2

I hope this mod will be useful to someone 😛

 
Last edited by a moderator:
New feature (v1.0.3) :
At Henshaw's request, there was added a command that performs a forced backup.
You can use the 'backup' or 'bp' command for this.

 
Last edited by a moderator:
Hello, I like the idea for this Mod, but I am running a Linux server.  Was wondering if  this Mod could be made to be  compatible with Linux? (Ubuntu).

 Thanks for your work! 

 
Any chance of a little less spam in the server console?  Just hard to see other stuff, doesn't need the announcement stuff imo, or at least not all the lines of it.

image.png

Great mod thanks man :D

 
Last edited by a moderator:
Hello, I like the idea for this Mod, but I am running a Linux server.  Was wondering if  this Mod could be made to be  compatible with Linux? (Ubuntu).

 Thanks for your work! 
Hi. I have just tried to install the mod on my Ubuntu virtual machine. It seems that the mod works fine. I think that you should try it yourself. 🤔

 
Changelog (v1.0.5) :
- The backup process is now completely asynchronous (no more freezes)
- The in-menu configuration hot-reload feature was reworked
- Now if the configuration is incorrect, you will be given detailed information about the error
- The 'backup info' command was added
- Some corrections in the announcements

 
Changelog (v1.1.0) :

- The 'backup restore' command was added

- File location announcement was removed from the chat announcements

- Much code refactoring

There is great news! Now you can restore your backups directly from the game menu, automatically!
Just write 'backup restore' in the game console and you will see your available backups.
image.png
Now write the 'backup restore *world id* *save id* *backup id*' command and enjoy. For example: 'backup restore 0 1 0'.

 
Last edited by a moderator:
Lots of errors for v1.1.0 so I have reverted to previous version which works fine.

From error log:

Code:
2022-05-02T06:42:13 322.827 EXC Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00011] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at BackupMod.Services.SaveInfoFactory.GetFromSaveFolderPath (System.String saveFolderPath) [0x0002f] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
  at BackupMod.Services.WorldService.GetCurrentWorldSaveInfo () [0x0000c] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
  at BackupMod.ModApi+<StartWatchdogForCurrentWorld>d__1.MoveNext () [0x00031] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDe@%$#Notification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at BackupMod.ModApi+<>c+<<InitMod>b__0_0>d.MoveNext () [0x0005d] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
UnityEngine.StackTraceUtility:ExtractStringFromException(Object)
Log:Exception(Exception)
BackupMod.Services.LogWrapper`1:Exception(Exception)
BackupMod.<<InitMod>b__0_0>d:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(<<InitMod>b__0_0>d&)
BackupMod.<>c:<InitMod>b__0_0()
ModEvent:Invoke()
<startGameCo>d__122:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

2022-05-02T06:42:13 322.830 ERR Full error message:
2022-05-02T06:42:13 322.832 ERR System.InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00011] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at BackupMod.Services.SaveInfoFactory.GetFromSaveFolderPath (System.String saveFolderPath) [0x0002f] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
  at BackupMod.Services.WorldService.GetCurrentWorldSaveInfo () [0x0000c] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
  at BackupMod.ModApi+<StartWatchdogForCurrentWorld>d__1.MoveNext () [0x00031] in <10452c9d1a9e493e9c0639f1ffa893fb>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDe@%$#Notification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at BackupMod.ModApi+<>c+<<InitMod>b__0_0>d.MoveNext () [0x0005d] in <10452c9d1a9e493e9c0639f1ffa893fb>:0
 
Changelog (v1.1.1) :

- Synchronization of backup and save directories is fixed

I have contacted MikeyUK to fix his bug and still waiting for the answer. This update may fix some problems.
If anyone else has some problems with the latest version of the mod, you should contact to me here or make an issue on GitHub.

 
Changelog (v1.1.3) :

- Configuration structure was changed

- 'Archive' feature was added (today's last backup will be stored and won't be deleted with 'General.BackupsLimit')
(Look at the new configuration)

- 'backup list' command was added

- 'backup delete' command was added

Note that the structure of the configuration file has been changed. You must replace your old settings.json with the new one and reconfigure it.

If anyone has some problems with this version of the mod, you should contact to me here or create an issue on GitHub.

 
Last edited by a moderator:
This is amazing thanks, all set up for me and seems to be running fine :D

LOVING the archive, really nice for admins!

 
Changelog (v1.1.4) :

- Recursive creation of folders if the Backups folder or the Archives folder was in the Saves folder has been fixed

If anyone has some problems with this version of the mod, you should contact to me here or create an issue on GitHub.

 
Hi,

just got a problem.

I manual delete SP saves and now Backup don't like to work anymore.

It give out error msg. because it can't access the old savegame folder's anymore.

And ofcouse it didn't do any backup's anymore.

Hmm, maybe i found the problem, there was still backups/archives with that names. And backup tried to lookup for these real  savefolder and they wasn't there.

Maybe you should add a failsafe. I don't think you can made a request to ask to delete these archives/backup when there isn't an actual save anymore.

Or at last the mod should still doing backup, even after the error.

 
Hi. Thanks for your report!
I have fixed this bug in the latest version of the mod.

But I don't have enough time right now to make a complete fix for this bug. So the missing directories will now be created all the time if there are backups or archives folders available. I'll change this behavior later

Changelog (v1.1.5) :

- Existing backups are unavailable for 'backup restore' and similar actions fix

If anyone has problems with this version of the mod, you should contact me here or create an issue on GitHub.
 
Last edited by a moderator:
Changelog (v1.1.7) :

Two new features were added:


// Skip the next scheduled backup, if there are no players on the server
// Default: false
"SkipIfThereAreNoPlayers": false

and

// Backup when the last player on the server disconnected
// Default: false
"BackupOnServerIsEmpty": false


If anyone has problems with this version of the mod, you should contact me here or create an issue on GitHub.




 
Last edited by a moderator:
Hi, this mod looks like a must have.  I'm wondering where to edit the settings file to backup my saves at this location - D:\7D2D\Mods\Saves  I'd like to backup that folder and put the backup archive(s) at D:\7D2D\Backups.  I did read over the instructions but it seems both areas are the backup locations.  Thank you.

 
Last edited by a moderator:
"CustomBackupsFolder": ""

Code:
 "CustomArchiveFolder": ""

from the first post... You can configure the modlet by modifying the 'settings.json' file, .  those two lines above i believe ar the ones to edit. i presume you add your custom path between the quotation marks.

 
Back
Top