Linux

Where Does SurrealDB Store Its Data?

SurrealDB stores data wherever the start command path points, with memory as the default and RocksDB or SurrealKV for disk.

Last updated

SurrealDB has no fixed data directory. Storage is whatever path you hand to the start command: memory for scratch work, rocksdb colon path for the production engine, surrealkv colon path for the newer disk engine. A relative path lands next to the working directory, which burns people who start the server from different folders.

For lasting installs, use an absolute path on persistent disk and back up that folder. Docker setups map a host directory (commonly /mydata in examples) and point the engine at it. The path, not the binary location, is the database.

Where SurrealDB stores this, by platform

Linux
rocksdb:/var/lib/surrealdb/mydb.db

Single node pattern. The folder after the prefix is the database. Use absolute paths in services so restarts from other directories keep working.

Linux
/mydata

Container convention from the official Docker examples. Map a host folder here and pass the matching engine path at startup.

Frequently asked questions

How do I persist SurrealDB data in Docker?

Mount a host folder into the container and pass it as the start path, such as a host mydata folder mapped to /mydata. Without a mount, the database dies with the container.

Does SurrealDB lose data on restart by default?

Yes. The default start with no path argument runs the memory engine, which is fast and disposable. Anything you need tomorrow must use a disk engine path.

Can RocksDB and SurrealKV share one directory?

No. Each engine writes its own file layout, so pointing two engines at one directory risks overwrites. Give every engine path its own folder.

Notice an outdated path? Let us know.