Backup / Restore

The Type-DB backup system generate a JSON string or file that can be imported at anytime.


To backup your data you need to use the methods Save() and Restore() of the Database object.

Basic Example

using (var tdb = new TypeDB.Core(Mode.Standalone).Connect())
using (var testdb = tdb.OpenDatabase("test", true))
testdb.Set<string>("hello", "world");
var backup = testdb.Save(); // export all entities in a JSON string
testdb.RestoreFromFile(@"c:\backup.json"); // restore an old backup from file

Backup on the fly or no

By default the Save() and Restore() methods return or restore datas from string but if you want to backup or restore to a file, you need to use SaveAs() and RestoreFromFile()

Please make sur to save in an existent location, otherwise a TypeDBGeneralException exception will be thrown.