Skip to content

Time‐Travel & Recovery

Lukatrum edited this page May 12, 2026 · 1 revision

"Time-Travel" & Rollbacks

Accidentally deleted a record? Overwrote important data? omni-json-db tracks internal states, allowing you to seamlessly recover data with a single line of code.

Recovering Modified Data (Undo)

jdb["config"] = "Version 1"
jdb["config"] = "Version 2" # Accidentally modified

# Revert to the previous state
jdb.revert("config") # equivalent to jdb.unmodify("config")
assert jdb["config"] == "Version 1"

Recovering Deleted Data (Unremove)

jdb["important_data"] = "Secret"
del jdb["important_data"]

# Bring the deleted data back
jdb.revert("important_data") # equivalent to jdb.unremove("important_data")
assert jdb["important_data"] == "Secret"

Full Database Backups

You can back up and restore the entire database efficiently:

# Backup the current state to a folder named 'bak'
jdb_bak = jdb.backup('bak')

# Restore the database from the backup folder
jdb.restore('bak')

Clone this wiki locally