Dungeons of Dredmor

Dungeons of Dredmor

29 ratings
Save Corruption/Fixes/Backup
By ひき
Have a corrupted save? Want to fix or, better yet, prevent it? How about just an automatic way to backup your save as you play? All this and more for the low, low price of the time it takes to read the guide!
   
Award
Favorite
Favorited
Unfavorite
Preventing: Corruption/Loss
Do all the following steps and live a full, Dredmor life... at least until you portal yourself smack dab into a monster zoo juiced up on acid drink.
  • Disable Steam Cloud.
    1. Right click the game in your Steam library
    2. Click "Properties"
    3. Click the "Updates" tab
    4. Uncheck the box at the bottom that says "Enable Steam Cloud synchronization for Dungeons of Dredmor"

  • As soon as you make a new character manually save and do a full backup, particularly of the copied mod files. If a save gets corrupted, the majority of the time it's actually because the save-specific copy of the mod files broke. Replacing the broken ones with a backup will fix it without rolling back your actual save data.

    If you're using the auto backup script at the bottom of this guide you can do the "first backup of a session" (aka a "full" backup) after saving your new character to have this process done for you... just make sure you do it ASAP so that you have a working copy of the mod files right away. And if you make multiple characters in a single session be sure to restart the autobackup tool each time.

    To do it manually:
    1. Go into your save folder (on Windows it is at "C:\Users\<yourusername>\Documents\Gaslamp Games\Dungeons of Dredmor\<yourcharactername>.dredmorsave")
    2. Make a backup somewhere else of all the "mod<numberhere>.dat" files (as well as everything else normally, but this initial backup is specifically for those mod files)

  • Make frequent backups of the entire "C:\Users\<yourusername>\Documents\Gaslamp Games\Dungeons of Dredmor\" folder, or at the very least your specific character's subfolder.
    Again, I HIGHLY recommend using the auto backup script at the bottom of this guide.

  • Keep multiple "full" and "minimal" backups at all times since you never know how far you may have to rollback a corrupted save.

  • Manually save frequently! The automatic backup script will work with in-game autosaves, but those always feel like a risky gamble... they also overwrite one another. To make 100% sure your saves are being applied to the proper character you should manually do it.

  • Restart the game every hour or so. The game simply stops updating saves at a certain point while playing... "solve" that by not letting it get to that point as frequently and, more importantly, without your knowledge (since even backups won't help you when this occurs).

  • If you have saves that you are particularly attached to make redundant backups on both physical and cloud-based mediums. You can pretty easily setup Dropbox (and similar services) to automatically update your cloud storage any time your save backups folder changes. This will be far more reliable and useful than Steam's game-specific cloud storage (which you should have disabled if you're following this guide correctly!).
Fixing: Already Corrupted Saves
There is a chance you can fix a corrupted save if it was related to the copied mod files breaking, even if you don't have "mod<numberhere>.dat" backups. If your save simply up and disappeared, or the corruption is actually the save itself, then backups are your only solution and you can skip this (and the Alternate Methods) section.

Continue on if you think yours is a broken mod file issue...

First things first: go to your save location at "C:\Users\<yourusername>\Documents\Gaslamp Games\Dungeons of Dredmor\<yourcharactername>.dredmorsave". Inside that folder you need to check if any of the "mod<numberhere>.dat" files are 0 KB in size.

If so follow the "NORMAL METHOD" below. If not you'll be using one of the "ALTERNATE METHODS".

NORMAL METHOD
VERY IMPORTANT NOTE: The following steps assume you have not unsubscribed (or re-subscribed) to any mods you were using in that particular save. The order the game uses for the mod list (and subsequently the numbering of the mod files we'll be trying to fix) is based on your subscription date order, not name or original upload date or anything. This means any 100% NEW subscriptions will be fine as they'll be at the bottom of the list anyways, but any other alterations will throw off the process.

If you can't be positive that your save is using the same mod order read through this method BUT ultimately skip to the bottom of this section and use the "ALTERNATE METHODS".

  1. Make a note of the number of the 0 KB file (i.e. the number in "mod<numberhere>.dat")
  2. Open Dungeons of Dredmor and go into the "Mods" menu. From the top of the mod list (going downwards), start counting the enabled mods from zero (NOT one!) until you reach the number you took note of. This means something like "mod5.dat" is going to be the 6th (enabled) mod down the list
  3. Look up that mod on the Steam Workshop to get the ID number at the end of the Workshop page URL (i.e. https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=<numberhere> ). It's easiest if you have the Steam URL bar enabled (in Steam go to View->Settings->Interface and check "Display Steam URL adress bar when available"). Keep in mind that the mod name on the Workshop may not be exactly the same as it is in game, so you might need to get clever with your searches.
  4. Go into your "C:\Users\<yourusername>\Documents\Gaslamp Games\Dungeons of Dredmor\steam_workshop\subscribed\" folder, and look for the .dat file inside that corresponds to the mod in question. The first part of the name will be the Workshop ID (i.e. "<idishere>-<anotherlongnumber>.dat"... you should be looking at the "idishere" part).
  5. Copy that .dat file and paste it inside your save folder (the same spot as your 0 KB "mod<numberhere>.dat" file)
  6. Rename the .dat you just pasted to match the empty "mod<numberhere>.dat" file. You'll have to move or delete the 0 byte file first, naturally


If you did it right you have now replaced the corrupted mod file with a fresh copy and your save should work!
Fixing: Alternate Methods
So your mod order isn't the same as it was when you made your character, eh? Or maybe you are having any number of other problems figuring out which mod you need to fix. Either way, you'll be following a similar method just with a bit more precise sleuthing. The purpose of these methods will be to figure out -all- of your "mod<numberhere>.dat" mod names.

Before anything make sure you read through the "NORMAL METHOD" above to get an idea of what you'll need and some of the processes you'll be using. Done? Okay, moving on!

ALTERNATE METHOD #1
  1. In your save location right click and open the "savegame.dat" file with a text editor. You may have to manually choose the program to use... Notepad or Notepad++ will be adequate.
  2. Inside will look like a lot of odd symbols, but it's the top of the file we care about. You should see some human readable text that relates to your character save folder. After that the rest of the readable text will be the list of all the mods you are using for that save in their appropriate order! It may be formatted strangely, but that is the order the game expects for your "mod<numberhere>.dat" files.
  3. Correlate those (remember to start counting from 0 (zero), not 1 (one)!!) to your "mod<numberhere>.dat" files and use "NORMAL METHOD" steps 3-6 to replace any broken files.


If this didn't work, move on to "ALTERNATE METHOD #2". A quick note: DO NOT under any circumstances make manual changes to the "savegame.dat" file. Doing so will immediately corrupt it and a backup will be your only option.

ALTERNATE METHOD #2
The first alternate method didn't work for some reason? Here's the more labor intense variation (and something of your last hope):
  1. In your save location open the first "mod<numberhere>.dat" with 7zip (these particular .dat files are just renamed .zip files)
  2. In 7zip, go into the "mod" folder. There may be others depending on the mod, but this is the only one we need to care about.
  3. Right click the "mod.xml" file inside and click "View" from the dropdown.
  4. Notepad should have opened. Find the line that looks like:
    <name text="Some Mod Name Here"/>
    Make a note of the name and corresponding number in the "mod<numberhere>.dat" name.
  5. Rinse and repeat this process for every "mod<numberhere>.dat" in the folder, skipping (but making note of the mod number) of any 0 KB and/or unopenable (aka corrupted) ones.
  6. If you had some 0 KB and/or unopenable "mod<numberhere>.dat" files:
    Compare the list of mods you've made note of to your overall mod list, figure out which one is missing, and then replace that one with a fresh copy (steps 3-6 of the "NORMAL METHOD" above).

    If you didn't:
    Replace every single one of the mods with a fresh copy in hopes that one of them just needed to be refreshed. Again, follow steps 3-6 of the "NORMAL METHOD" above for each mod file.

Scripting: Automatic Backups
So you got everything all setup to keep your saves safe, but you're sick of doing it manually, right? Well here's a quick-and-dirty solution for you. Below is a script you can (and should) run while playing the game that will automatically backup your saves every X minutes.


WHAT IT DOES:
On the first run of each session it will immediately backup everything save-related in the overall save folder. That includes a copy of the mods used for each character! After that (i.e. subsequent backups while playing that same session) it will only backup the save files themselves. Why? Well, there's no reason to constantly backup the mod copies as they don't change... unless they get corrupted, that is.

Keep known-working versions of the "full" backups around as they will contain what you need should your mod files corrupt. The minimal backups are purely for if the actual save file(s) get corrupted or lost.

HOW TO CONFIGURE IT:
  1. Download and install 7-zip if you don't already have it. https://www.7-zip.org/ This is what will be bundling up the save folder.
  2. Copy the code below into a text document. I suggest using something like Notepad++ https://notepad-plus-plus.org/
  3. Change the following variables at the top of the script to meet your needs (see the code for an example of how it should look).
    • ZIPLOCATION = the full location of your 7zip executable. Leaving this as default is probably fine if you have a standard setup and chose to install the 64bit version.
    • ZIPQUALITY = the level of compression to use. The value can be 0,1,3,5,7, or 9. 0 = store (ie no compression), 5 = normal, 9 = ultra, etc. Whatever your computer can handle without lagging the game will be fine. The minimal saves are very, very small, so 0 is what I'd recommend.
    • FOLDERTOBACKUP = the full location of the folder to actually backup. In this case you will want to use the "\Gaslamp Games\Dungeons of Dredmor\" folder in your My Documents.
    • TIMER = How often to make a backup while the script is running, in minutes. Default is every 15 minutes.
  4. Save the file as "<whateveryouwant>.bat" The important part is the ".bat" extension. Backups will be stored in the same location as this file, so I'd suggest making a "DoD Backups" folder to keep everything in. You can always toss a shortcut to the .bat on your desktop after all.
  5. Run by double clicking it. A command prompt will open up, an initial "full" backup will occur, then the timer for subsequent "minimal" backups will start running.

After doing your first backup you should double check the generated file to make 100% certain it all worked as it should.

THE SCRIPT:
@SETLOCAL ENABLEDELAYEDEXPANSION @ECHO OFF :: ---- STUFF YOU NEED TO CHANGE FOR YOUR SETUP ----- set "ZIPLOCATION=C:\Program Files\7-Zip\7z.exe" set "ZIPQUALITY=0" set "FOLDERTOBACKUP=C:\Users\yourusernamehere\Documents\Gaslamp Games\Dungeons of Dredmor\" set "TIMER=15" :: ---- --------------------------------------- ----- :: ------ DO NOT CHANGE ANYTHING BELOW UNLESS ------ :: ----- YOU KNOW WHAT YOU'RE DOING, SERIOUSLY! ---- set "FIRSTTIME=TRUE" :: start it up! goto :DoTimer :DoBackup :: get the time for /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') do ( if not "%%~F"=="" ( set /A SortDate = 10000 * %%F + 100 * %%D + %%A set YEAR=!SortDate:~0,4! set MON=!SortDate:~4,2! set DAY=!SortDate:~6,2! set /A SortTime = 1000000 + 10000 * %%B + 100 * %%C + %%E set HOUR=!SortTime:~1,2! set MIN=!SortTime:~3,2! set SEC=!SortTime:~5,2! ) ) if !FIRSTTIME!==TRUE ( set "TEMPFILENAME=!YEAR!!MON!!DAY!-!HOUR!!MIN!!SEC!-IncludesModData.7z" "!ZIPLOCATION!" a -mx!ZIPQUALITY! "!TEMPFILENAME!" "!FOLDERTOBACKUP!" set "FIRSTTIME=FALSE" -xr^^!steam_workshop -xr^^!mods ) else ( set "TEMPFILENAME=!YEAR!!MON!!DAY!-!HOUR!!MIN!!SEC!.7z" "!ZIPLOCATION!" a -mx!ZIPQUALITY! "!TEMPFILENAME!" "!FOLDERTOBACKUP!" -xr^^!steam_workshop -xr^^!mods -xr^^!mod*.dat ) echo. echo ------------------------------- echo Backup made: !TEMPFILENAME! echo ------------------------------- echo. echo #################################################### echo ############ Minimal backup starting... ############ echo #################################################### goto :DoTimer exit /B :DoTimer :: repeat on a loop, in seconds if !FIRSTTIME!==TRUE ( echo #################################################### echo ############ DOING FULL BACKUP FIRST... ############ echo #################################################### ) else ( echo Starting timer... set /A "temptimeout=!TIMER! * 60" timeout /t !temptimeout! ) goto :DoBackup exit /B
Answering: Questions
  • Q: The game keeps saying it's missing mods, what gives?
    A: You're missing the appropriate "mod<numberhere>.dat" files then. If you're restoring a backup from the automatic backup script in this guide you'll need to get those from the "full" backup (the one with "IncludesModData" appended to the end). The other, smaller backups are -only- the save info so you have to combine the two.

  • Q: My save is still broken!
    A: Sorry to hear that. This guide isn't a guarantee, but it should help mitigate the gut-punch a corrupted save can give, especially if you've followed all the steps BEFORE a corruption occurs.

  • Q: I don't even use mods, yet my save is still corrupted?
    A: Backups are, unfortunately, the only current remedy for "true" save corruption. If you don't have any, then you're likely out of luck this time.

  • Q: How do I use this guide if I have non-Workshop mods?
    A: That is something I'll have to look into and will be added to the guide in the future (maybe). The general idea should be the same, but obviously the step-by-step details will be different.

  • The automatic backup takes forever and/or makes my game lag!
    A: Lower the compression quality. Setting it to "0" (zero) will do no compression whatsoever and is the fastest/least resource-intense. The filesizes won't be any smaller, but unless you have a ton of characters the backups aren't too big anyways.

  • Q: I keep crashing when I do <insert super specific thing here>, is my save corrupted?
    A: Maybe, but I would hazard a guess that it's more likely to be a bug in a particular mod that you're using. The exception would be if a particular level of the dungeon got corrupted and you keep trying to go to it.

  • Q: Will this work with autosaves?
    A: Yes, but you should manually save frequently to make 100% sure your saves are being applied to the proper character.

  • Q: My autosave is what broke, how do I fix it?
    A: You follow the same general steps, but instead of a "<characternamehere>.dredmorsave" folder you're going to be using "autosave.dredmorsave".

  • Q: Will this guide help with crashes?
    A: Not unless they are related specifically to loading a corrupted save.

  • Q: Will this work on Linux/MAC?
    A: No, but sort of. The general practices and overall methods (excluding the script) will BUT the paths aren't going to be the same. The script, on the other hand, will not work without some tinkering. In particular the method I use to generate the date for unique filenames relies on specific Windows stuff, and the commands might not all match up 100% with terminal syntax. It should be easy enough for you to adjust it though... it's not like it's very complicated.

  • Q: Why does the game do this?
    A: Who knows. Programming is tricky business in the best of times, and this was their first game. There are a lot of moving parts and an absurd amount of data... a single typo can bring the whole thing down.

  • Q: Can you help me fix <insert different kind of problem here>?
    A: I make no promises, but if you have specific information about what is causing a problem (especially if you know what mod is doing it) then I may be able to look through the code to see what's going on.

  • Q: Why did you make the script in batch?
    A: Because I love batch! It's wonderfully limited, can do some really weird stuff, and (most importantly) is forcibly open source. Compiled scripts for something like this give me the heebiejeebies. Ain't no need for that kind of fancy city-talk 'round here.

  • Q: Your automatic backup script sucks!
    A: Somewhat, yes. It does what it needs to do. I made a very, very in-depth variation of this script (with menus and ANSI art and everything!) for Terraria and it was just too much work to re-tool for this purpose. I'm also not interested in a larger programming project at the moment. There are indeed much more... "efficient" (read: less characters/lines used) ways to make the script I did, but it was just a quick-and-dirty job.

  • Q: <insert info here> is wrong/poorly explained/etc. in the guide!
    A: Let me know and I'll make a fix ASAP!

  • Q: No english, guide plz.
    A: Use an automatic translator and hope for the best.

  • Q: Will your automatic backup script work for other games?
    A: Yup! Though you'll need to do some tweaking. Specifically: the save folder location. There are other bits that are Dredmor-specific, but they shouldn't impact anything too severely.

  • Q: Can you help me change the script for a different game?
    A: Maybe, though learning to do this yourself is the gift that keeps on giving. If you have the specific information on where saves are stored and what files are/aren't needed then I can probably figure something out for you.

  • Q: Hey aren't you the person that was working on that other Gaslamp Games project?
    A: Shhhh. Sometimes the past is the past for a reason.
3 Comments
Count Viscount 20 Jul @ 2:52pm 
The game has now resorted to deleting everything in the character folder except for the data for one single mod. This is driving me crazy.
Count Viscount 20 Jul @ 1:57pm 
How do I know which of the mods in the savegame.dat are broken? What indicates whether it's working or broken in the file?
Scoot 22 Nov, 2023 @ 1:59am 
Combining the the save backups with the mods files does not seem to work. Also, when I start the game, sometimes it just... deletes the savefiles in the folder for some reason?