You are viewing a potentially older version of this package. View all versions.
hiccup-SaveBackups-1.2.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 a month ago
Version 1.2.0
Download link hiccup-SaveBackups-1.2.0.zip
Downloads 1076
Dependency string hiccup-SaveBackups-1.2.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)]

This attribute is worth adding even though the API no longer needs it. BepInEx starts plugins in plugin id order, so without it your mod may well start before this one.

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",
        SaveBackups.Companions.SanitiseSaveName(saveName) + ".json"));

The save name arrives exactly as the game stores it, punctuation and all. If you key your files by a cleaned up version of that name, call SaveBackups.Companions.SanitiseSaveName rather than writing the rule yourself, so your filenames always agree with the ones this mod looks for.

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, every call works through reflection against the SaveBackups.Companions type. Check IsAvailable to confirm the type resolved before registering.

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
MaxPreRestoreBackups 5 Safety snapshots kept per save, taken automatically just before each restore. 0 keeps everything
BackupsPerPage 6 Backups listed per page. Use the arrows at the bottom to reach older ones
ButtonGap 14 Spacing between Delete, Load and Backups on the save info panel
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.4.0

  • Every backup row now has an edit button. It opens the backup in a panel below the list, showing the whole snapshot at once: the save name, money, current and furthest island, motor, boat skin, difficulty, playtime and player count, plus whether the boat, radar, grill, final boss and ending are unlocked.
  • Anything in that panel can be changed. Type a new name or a new balance, cycle the difficulty, click a toggle. Save changes writes it back to the backup, Cancel throws the edits away.
  • Saving is done carefully. The mod keeps the untouched original beside the backup as save.txt.pre-edit, writes the new version to a temporary file, reads that file back to prove it still parses, and only then puts it in place. If anything goes wrong nothing is overwritten and the panel says so.
  • Only the fields shown in the panel are touched. Everything else in the save, including the world items and the per-player records, is carried across exactly as it was.
  • The editor also lists the mod files stored in that backup, with the file each one came from and how large it is, and a bin button to remove one. Removing takes two clicks, deletes the file and drops it from the snapshot's record of itself. The rest of the backup is untouched.
  • Unlocked skins are deliberately absent from the editor. The game keeps them in its own local file rather than in the save, so they are shared by every save and are not part of a backup. There is a line in the panel saying as much, so it does not look like an oversight.
  • The page shows ten backups at a time instead of six.
  • The list is now a proper table, with a column each for the star, the time taken, the name, the island, the money, the time played and the mod file count. Money and time played are read out of the snapshot itself, so you can tell two backups apart without restoring either.
  • The row buttons are icons instead of words: a pencil to edit, an arrow to restore, a bin to delete. Hovering any of them says what it does.
  • The panel opens on the right hand side of the Load Game screen, in the space the game leaves empty, so it no longer covers the save list or the save info. Pressing Back in the lower left closes it along with the screen.

1.3.0

  • Backups can be starred. A starred backup is pinned to the top of the list and is never deleted to make room, however many autosaves happen afterwards. Unstar it and it rejoins the normal rotation, and deleting it by hand still works. Starring is remembered per save, and works on backups taken before this update.
  • Starred backups no longer count toward the number of automatic backups kept, so keeping one does not cost you a rotation slot.
  • Hovering the mod file count on a row now lists which mods are in that snapshot, instead of only telling you how many there are.
  • The star grows slightly while the pointer is over it, so it is obvious it can be clicked.

1.2.0

Companion API

  • Fixed the companion API failing for any mod whose plugin id sorts before this one. BepInEx starts plugins in id order, so a mod registering from its own startup could run before this mod had set up its logger, and the registration call threw instead of completing. The logger is now ready before any other mod can reach the API.
  • Added Companions.SanitiseSaveName, so companion mods can turn a save name into the same filename this mod uses without copying the rule into their own code. Copied rules drift apart over time and then the wrong file gets backed up.
  • Added Companions.IsAvailable for soft dependency checks.

Backups that do not lose data

  • Quitting the game straight from a session now backs up that final save. The capture was scheduled for the end of the frame, and no further frame runs during shutdown, so it was being dropped silently.
  • Restoring now clears mod data that the snapshot predates. Previously an old save could be restored while a companion mod kept its newer file, leaving the save and the mod data describing different worlds.
  • The save file and every companion file are now written through a temporary file and swapped into place, so a crash or power cut during a restore can no longer truncate a save.
  • Safety snapshots taken just before a restore are recorded as their own kind and pruned on their own budget, set by MaxPreRestoreBackups. They were being stored as manual backups, which are never pruned, so every restore grew the folder permanently.
  • Taking a backup no longer reads and parses every stored snapshot twice, which removes a growing stall from every autosave.
  • Two snapshots taken in the same second no longer produce a folder name that fails to parse, which could mislabel a manual backup as automatic.
  • Saves whose names differ only by characters that are illegal in filenames no longer see each other's backups.

The Load Game screen

  • Fixed the Load button doing nothing after returning to the main menu from a session. This mod was re-showing the save info panel after the game had deliberately hidden it and cleared the selection, so the Load button was visible while no save was actually selected, and pressing it failed. The panel now stays hidden until you pick a save again, which is what the game intends.
  • The panel borrows the frame from the game's own save info panel instead of drawing a flat black rectangle, so it matches the menu and will keep matching if the art changes.
  • Backups are laid out as a table. The timestamp has its own column so dates line up, with the details beside it, and rows are tinted in alternating bands so a full page is readable at a glance.
  • The Backups button now sits beside Delete and Load instead of below them. The three share the space the game gave to two.
  • Deleting asks once, on the button itself. Only one backup can be armed at a time, and backing out of the panel cancels it.
  • The list is paged six at a time, with arrows and a total at the bottom and a page counter beside the title.
  • Fixed the Open folder button building a malformed path on Windows.

Configuration

  • Renamed MaxRowsShown to BackupsPerPage. The old name is left behind in your config file and ignored; delete the line if you like.
  • Removed OpenButtonWidth and OpenButtonBottomMargin. They only applied to a fallback layout that is no longer used, and that fallback now takes its size from the game's own buttons.

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.