You are viewing a potentially older version of this package. View all versions.
hiccup-SaveBackups-1.1.0 icon

SaveBackups

Automatic rolling backups of your save files, with a Backups tab in the Load Game screen. Restores mod data alongside the save, so a snapshot puts everything back together.

By hiccup
Date uploaded 2 hours ago
Version 1.1.0
Download link hiccup-SaveBackups-1.1.0.zip
Downloads 19
Dependency string hiccup-SaveBackups-1.1.0

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2305 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2305

README

SaveBackups

Modded games break saves sometimes. This keeps rolling copies of yours and lets you put one back from inside the game.

A Backups button appears on the Save Info panel in the Load Game screen. It lists every backup of that save with when it was taken and what is in it, and each row has Restore and Delete.

Aug 23  18:44  (manual)   2877 money, island 4, 4h 45m played   [Restore] [Delete]
Aug 23  18:44             2677 money, island 4, 4h 46m played   [Restore] [Delete]
Aug 23  18:43             2877 money, island 4, 4h 45m played   [Restore] [Delete]

The money, island and playtime are read out of each backup file, so you can tell which one you actually want instead of guessing from a timestamp.

When backups happen

Automatically every time the game saves, which includes the five minute autosave, and again when you pick a save to load, so you always have the state you started a session with. You can also take one on demand with Back up now.

Identical saves are skipped, so sitting idle does not fill your history with copies of the same thing. That means the slots you keep hold genuinely different states.

Restoring is safe

Restoring takes a backup of the current file first, marked manual, so restoring is itself undoable. If you pick the wrong one you have not lost anything.

Manual backups are never deleted automatically. Only automatic ones rotate, keeping the newest few. This matters: if manual backups were pruned too, a handful of autosaves after something went wrong could quietly delete the good copy you were relying on.

The mod also refuses to back up or restore an empty file, since an empty save is what corruption usually looks like and copying it over your history would destroy the thing you need.

Mod data is included too

Some mods keep their own save data in a separate file. If only the vanilla save were rolled back, you would end up with a mismatched world: base state from the snapshot, mod state from now.

A snapshot therefore holds the save and any registered mod files together, and restores them as one unit. Rows carrying mod data are marked with a + and a count.

If you restore a snapshot whose mod is no longer installed, the save is restored anyway and the panel tells you which data was skipped.

For mod authors

If your mod writes its own per save file, two lines make it part of every snapshot.

Add a soft dependency so your mod still runs without SaveBackups:

[BepInDependency("dazed.howtofish.savebackups", BepInDependency.DependencyFlags.SoftDependency)]

Then register in Awake, returning the absolute path for a given save name, or null if that save has no file:

SaveBackups.Companions.Register(
    "yourmodid",
    "Your Mod Name",
    saveName => Path.Combine(Paths.ConfigPath, "YourMod", "Saves", Sanitise(saveName) + ".json"));

That is the whole integration. SaveBackups copies the file when it snapshots and writes it back when you restore, creating directories as needed. A missing file is normal and is not an error.

If you would rather not reference SaveBackups at all, the same call works through reflection against the SaveBackups.Companions type.

Where the files live

%USERPROFILE%\AppData\LocalLow\Dazed Games\How to Fish\SaveBackups\<save name>\<timestamp>\
    save.txt
    companion.<modid>.json
    snapshot.json

They are plain copies of the real files, so you can also just copy one back by hand if you prefer. Open folder in the menu takes you straight there.

Backups made before version 1.1.0 were single files rather than folders. Those are still listed and still restore, as save only snapshots. Nothing is migrated or rewritten.

Configuration

BepInEx/config/dazed.howtofish.savebackups.cfg

Setting Default What it does
BackupOnSave true Back up on every save, including the autosave
BackupOnLoad true Back up when a save is selected to load
SkipUnchanged true Do not store a copy identical to the newest one
MaxAutomaticBackups 10 Automatic backups kept per save. 0 keeps everything
MaxRowsShown 7 Rows listed at once, so the panel does not overflow
OpenButtonWidth 240 Width of the Backups button
OpenButtonBottomMargin 22 Gap between the Backups button and the panel edge
DeferCapture true Copy files at the end of the frame so mod data is captured in step with the save

Disk use is modest. Save files are small, and 10 backups of a save is still well under a megabyte.

Notes

Singleplayer and hosted saves both work, since these are the server save files. Only the host has them, so joining someone else's game has nothing to back up.

Nothing is overwritten without being copied first, and no game files are modified. Removing the mod leaves your saves exactly as they are, and the backup folder can be deleted freely.

CHANGELOG

Changelog

1.1.0

  • Snapshots can now include files belonging to other mods, so a restore puts the whole save back rather than just the vanilla part.
  • Added a public API other mods can call to register their own save files. See the README for the two lines needed.
  • A snapshot is now a folder holding the save, any companion files, and a manifest describing what is inside.
  • Backups made before this update are still listed and still restore, as save only snapshots. Nothing on disk is migrated or touched.
  • File copying is deferred to the end of the frame. Other mods write their data from the same game event and the running order is not guaranteed, so this makes sure a snapshot holds the save and its companion files from the same moment.
  • Restoring a snapshot whose companion mod is no longer installed now restores the save and says which data was skipped, rather than failing.
  • Rows show a marker when a snapshot carries companion data.

1.0.0

Initial release.

  • Automatic rolling backups of server save files, taken on every save including the five minute autosave, and when a save is selected to load.
  • Backups tab built into the Load Game screen, using the game's own button styling.
  • Each row shows when the backup was taken plus the money, island and playtime read from the file itself.
  • Restore and Delete per backup, plus Back up now and Open folder.
  • Restoring takes a backup of the current file first, so a restore can itself be undone.
  • Manual backups are never pruned. Only automatic ones rotate.
  • Identical saves are skipped so the history holds genuinely different states.
  • Empty save files are refused for both backup and restore.
  • The save list and the save info panel refresh in place after a restore, so the restored values show immediately.