[TOOL] SimpleMedianBackup v1.1.1 - saves/etc. backup tool for Windows users

Discuss Median XL!
User avatar
Esbee
Cultist
22 | 19
Common Popularity Badge
Has a thread with over 10.000 views
Image
S I M P L E M E D I A N B A C K U P

Latest Version: v1.1.1 | Download: https://mega.nz/file/nN5xSYga#jgMSBMMN- ... lUjU-s0TtQ
Or the last resort mirror:
► Show Spoiler


Tired of losing hundreds of hours of progress because of corrupted/disappearing/broken/etc. singleplayer or TCP/IP saves? Want the ability to make and have snapshots of all your characters, stashes, etc. before playing/updating so that you can quickly revert if something goes wrong? Then SimpleMedianBackup (a simplified derivation of my old SimpleTerrariaBackup script) might be the tool for you! Note: this IS NOT a hack/cheat tool. All it does is automate zipping up your own personal save folder.

This is a small application written in MS-DOS Batch (using command prompt, not actual DOS obviously) to backup any Windows-edition Median XL singleplayer and TCP/IP saves. Why another backup utility when others exist out there, you ask? I'm not a fan of compiled tools when it's not necessary, others came with too many unrelated features, some are reliant on a specific game version and/or didn't allow for an unlimited number of backups, and... well... Batch is super fun.

Current Features:
    Backups:
      - Instant backup as soon as the script is (successfully) launched
      - Automated backups every X (default is 5) minutes while playing
    Support:
      - Non-standard installs can be used with minimal manual config edits
      - Works with all previous and future versions of (Windows edition) Median XL
      - Works for both Singleplayer and TCP/IP
      - Both 32bit and 64bit 7-Zip supported
    Quality of Life:
      - No limit to the amount of backups you can make
      - No auto-"old backup" deletion
      - Backups use timestamps in the folder/name, for automatic organization
      - Attempted automatic detection of drive/folder paths
      - Micro RAM footprint
      - Adjustable auto backup timer
      - Configurable 7-Zip compression levels
      - Configurable backups can include characters, stashes, maps, and/or misc files
    Misc:
      - Completely open, non-compiled code
      - ANSI visuals for an appropriately retro terminal/BBS feel

Requirements:
    - Windows 7 and above (XP/Vista *might* work, but I'm not sure)
    - 32/64bit 7-Zip (http://www.7-zip.org)
    - Diablo II and Median XL

How to Use:
    1. Unzip the download wherever you want (your backups will be stored here as well, so pick a convenient spot)
    2. Run SimpleMedianBackup.bat (you may need admin privileges)
    3. Settings will auto-generate, but if your paths aren't located you'll need to make manual changes to the generated "config.cmd" file (see "SETTINGS" in SMB.README.txt for info)
    4. (Optional) Configure any options you want to change and restart
    5. Let it run while you play, and you're done!

    It is highly recommended that you double check the first few backups you make, just to be sure everything is working as intended. If you're on a lower end computer, you may want to adjust the 7-Zip Compression settings before use.

How to Restore:
    Unzip the backup you want to use into the appropriate folder and say "yes" to overwriting the files. The exact location will depend on your system. You should be able to get a hint as to where to unzip your files if you open "config.cmd" in a text editor and see how the paths were configured. The examples in the "SETTINGS" section in SMB.README.txt will give you a general idea of where a standard installation of Median XL will have everything located.

    Typically this is at: %appdata%\MedianXL\save\

Notes:
    - READ THE README, especially if you are using any custom config options
    - Backups are stored wherever the SimpleMedianBackup.bat file is located
    - Feel free to edit the code all you want, aside from selling it or making it malicious in any way. It's not the greatest or most organized code out there, but should be fairly logical. Just remember that you MUST open and save the .bat file in ANSI. UTF will completely break the functionality as all ANSI characters will get corrupted, and encoding to ANSI after opening in UTF will not work properly

Future Plans:
    - Possibly re-adding some of the more complex features that my other versions of the script has
    - Any bugs that pop up
    - MORE AND BETTER ANSI, when the mood strikes

Changelog:
v.1.1.1 (2021-09-04)
- Script now forces itself to run in the intended directory (no more admin-mode, remote execution, etc. issues)
- Improvements to data validation for true/false configuration options (they're no longer CaSe SenSiTive)
- Added check on startup to see if another instance is running, halting if so
- Added a -debug option that will add pauses and some verbose text to various stages of the process. (not recommended to use unless I request it for troubleshooting)

v1.1.0 (2021-08-30)
- Default 7-Zip compression changed from 3 to 9 (ultra compression as default shouldn't be an issue for most)
- Added "BackupCharacters" filter to specify if .d2s files should be included
- Added "BackupStashes" filter to specify if .stash and .shared files should be included
- Added "BackupMaps" filter to specify if .map, .ma0, .ma1, .ma2, etc. files should be included
- Added "BackupMisc" filter to specify if .key and .json files should be included
- Added UI to indicate what filters are in use
- Added some basic data validation for certain configuration options
- Changed UI "ATTEMPTS" wording to "BACKUPS"
- Removed UI "Retries" counter
- Adjusted various UI text
- Fixed a few issues in SMB.README.txt

v1.0.0 (2021-08-30)
- Initial release


Older Versions:
Older versions are NOT recommended!
► Show Spoiler
Edited by Esbee 3 years.
User avatar
iwansquall
Gore Crawler
1523 | 71
Common Posting Badge
Posted over 1.000 messages
Legendary Popularity Badge
Has a thread with over 250.000 views
Common Love Badge
Earned over 20 cookies
Common Supporter Badge
Donated 1 time
Cool, i just posted about this suggestion to combat current bad inventory data problems.

Thx for the tool.
User avatar
Esbee
Cultist
22 | 19
Common Popularity Badge
Has a thread with over 10.000 views
The 'bad inventory data' issue is indeed why I fast-tracked getting this setup. Normally I would have made it far fancier, but I got sick of losing saves that I could have instead just rolled back a bit.

Keep in mind that if you're using this for that you still need to pay attention to the telltale trigger: when you pick up an item (or transfer it in/out of the cube or stash) and it disappears instead. The game will still let you play, and that means any further save backups will be corrupted if you didn't notice. If you catch it right away the most you will have lost is ~5 minutes of time.
afgusto
Prowler
17 | 1
You have provided a whole tool faster than the devs managed to even address the bug, big respect :)
User avatar
iwansquall
Gore Crawler
1523 | 71
Common Posting Badge
Posted over 1.000 messages
Legendary Popularity Badge
Has a thread with over 250.000 views
Common Love Badge
Earned over 20 cookies
Common Supporter Badge
Donated 1 time
In bad inventory data thread, i already suspected that the symptom for some of the SP crashing.

However, Im still puzzling why pressing shared stash will make the game hang.
I cant replicate it, but mostly happened if 2 instance of d2 running.

I hope this batch files dont get too crazy with multiple files
I have dealt with certain "not good" tools that can get crazy if you left it on too long on your pc.
Not that ppl gonna run the game 24/7, but it still about 12 backups per hour, per characters (assuming you have multiple characters)

Keeping latest XX copies backup files is probably what i think next feature should be
User avatar
Esbee
Cultist
22 | 19
Common Popularity Badge
Has a thread with over 10.000 views
afgusto wrote:You have provided a whole tool faster than the devs managed to even address the bug, big respect :)

As much as I would love to bask in praise, mine was an incredibly easy task whereas theirs is not even close to that. Plus I already had a different version of this for other games, so it was mostly a matter of ripping out the vital guts and redoing a few things here and there.

iwansquall wrote:I hope this batch files dont get too crazy with multiple files
I have dealt with certain "not good" tools that can get crazy if you left it on too long on your pc.
Not that ppl gonna run the game 24/7, but it still about 12 backups per hour, per characters (assuming you have multiple characters)

Keeping latest XX copies backup files is probably what i think next feature should be


The "too many files" problem is only going to happen under two cicumstances:

1) You leave the game AND the backup tool running for days on end. Closing either will put auto-backups on pause (this is why the script tries to detect if Game.exe is running)
2) You don't periodically purge old files manually

All backups are put into their own daily folder (by date), so it is incredibly easy to remove old backups you no longer need. And there are no character-specific backups that could clog things up as ALL characters/stashes/etc. are stored in a single .7z for this very reason. Compressed saves, even with lots of characters, don't take up much room... especially if you set the 7-zip compression option to "9".

Auto-purging is not planned, as that is an intentional decision on my part and something I dislike in other backup tools. That said, the version of this script I made for Terraria (and what this one is based on) has some safeguards in place that I may implement here when I'm less exhausted. Primarily: that version has an auto backup limit that will stop the process if X number of backups have been made in a single session. Setting this to something sensible (100 max with the 5 minute timer would be 8+ hours of continuous play) would at the very least prevent massive redundant saves if someone leaves both the game and the tool running overnight... though in all honesty the best solution for that is: don't leave it running. There's only so much one can do to idiot-proof things, and it's never a fun task ;)
User avatar
prawn
Invader
9 | 1
Does the tool work if you are either the host or the joiner? Or is it only the host that can use this?

Usually the joiners game only saves when they save and exit doesn't it?
eleriaqueen
Destroyer
6 | 1
Hello, this tool seems useful to me though I wonder why depend on 7zip ? Windows can zip files natively, no need for 7z algorithm for such small files anyway.
User avatar
Esbee
Cultist
22 | 19
Common Popularity Badge
Has a thread with over 10.000 views
prawn wrote:Does the tool work if you are either the host or the joiner? Or is it only the host that can use this?

Usually the joiners game only saves when they save and exit doesn't it?


In my tests both joiner and host save (character, stash, and shared stash, though shared stash is borked at the moment in TCP/IP as you may know) at the 5 minute mark, just like normal singleplayer.

HOWEVER, I do not have the ability to remotely test and instead have to rely on self-hosted and self-joined games from the same computer and may have been hasty in assuming it works the same way. If you (or anyone) can test a "real" TCP/IP game that would help clarify it. All anyone would have to do to test is join a game someone else is hosting and stare at their %appdata%\MedianXL\save\ folder and the "Date Modified" value for their character's .d2s and .stash files. After 5 minutes of having joined a game those files should get updated (you may have to manually refresh the folder view, since sometimes Windows likes to desync visually). If it did, then joiner saves work as I have assumed and (locally) tested. If not, then they do not and I will need to amend some text to make sure that is made more clear.

eleriaqueen wrote:Hello, this tool seems useful to me though I wonder why depend on 7zip ? Windows can zip files natively, no need for 7z algorithm for such small files anyway.


Mostly because this script is a variation of one for games that did indeed have very large files, and those with lots of characters will still appreciate that they have control over the compression level. That, and I absolutely loathe the Windows zip functionality (and, conversely, quite love 7-Zip). 7-Zip is a standard nowadays, so I see no reason not to utilize it.
Edited by Esbee 3 years.
User avatar
Seikun
Azure Drake
175 | 10
You're our savior.

Although I personally decided to wait until devs do something. If they even bother. Having auto-backups is nice, but it doesn't solve problem of loot disappearing.