Backup & import
Export a collection to portable JSON and restore it.
Export and import a collection
Export a collection to a portable, identity-preserving JSON document and restore it later, into the same collection or a
new one. Import supports Replace (clear the collection first) and Merge (upsert by
id), and recreates the collection if it does not exist. It works from code, and from the Management UI's
Collections page.
ReplaceClears the collection first, then loads the export.
MergeUpserts by id into whatever is already there.
Plaintext JSONIdentity-preserving and portable, and never encrypted.
using NetlyDB.Core.Persistence;
var docStore = host.Services.GetRequiredService<IDocumentStore>();
// Export a collection to portable, identity-preserving JSON
using (var file = File.Create("orders.netlydb.json"))
{
CollectionBackup.Export(docStore, "Order", file);
}
// Import: Replace clears the collection first; Merge upserts by id. Recreates the collection if needed.
using var restore = File.OpenRead("orders.netlydb.json");
var result = CollectionBackup.Import(docStore, "Order", restore, ImportMode.Replace);
Scope
- Backup is per collection. There is no database-wide consistent backup, and no point-in-time restore.
- Rolling back to an earlier NetlyDB version is done by restoring a backup; downgrade is not supported.
Database-wide backup and restore, and point-in-time recovery, are Planned roadmap work. See the project status.