Reference / Backup API for Rust
Backup API for Rust
Every public type, trait and function of the Backup engine in tinystore::backup and tinystore::aio::backup, generated from its source. The Backup guide explains how to use them, and the Bun and Node, Python and Go pages list the same API.
Store
impl StoreStore.backup
pub fn backup(&self) -> BackupBuilderA backup of every engine of the store, made while it keeps working.
aio::Store
impl aio::Storeaio::Store.backup
pub fn backup(&self) -> BackupBuilderA backup of every engine of the store, made while it keeps working,
as crate::Store::backup builds one.
restore
pub fn restore(archive: impl AsRef<Path>, dir: impl AsRef<Path>) -> Result<Backup>Restores the backup at archive into dir, which is empty or absent,
before a store opens there; the store's LOCK is held meanwhile, so that
none opens before the restore ends. A file that does not match what the
backup says of it fails the restore Corrupt, and leaves dir empty.
verify
pub fn verify(archive: impl AsRef<Path>) -> Result<Backup>Checks the backup at archive as restore checks it, and writes
nothing: its zip's directory and manifest, each file's size, CRC-32 and
SHA-256, and on Windows the names Windows reads as devices. What it
answers is what a restore of it writes; a file that does not match what
the backup says of it is Corrupt, naming the file.
let backup = tinystore::backup::verify("backup-2026-10-13.zip")?;
println!("{} files, {} bytes a restore writes", backup.files, backup.bytes);Backup
pub struct Backup {
pub files: usize,
pub bytes: u64,
pub key_left_out: bool,
pub excluded: Vec<String>,
}What a backup holds.
BackupBuilder
pub struct BackupBuilder { /* private fields */ }A backup about to be made: the files of the program's it takes beside the engines', and whether it takes the store's encryption key.
BackupBuilder.include
pub fn include(self, name: &str) -> SelfIncludes a file of the program's, by its path inside the store's
directory, such as secret.key, which a restore puts back where it
was. A backup holds no file but the engines' unless one is named.
BackupBuilder.include_encryption_key
pub fn include_encryption_key(self) -> SelfIncludes the store's encryption key, as it is, which a backup leaves out otherwise: the zip is not encrypted, so a backup with the key opens every value it holds, and is kept as safely as the key. While values are sealed, a key that is not where the store reads it fails the backup, as beside a server that keeps its key apart.
BackupBuilder.write
pub fn write(self, path: impl AsRef<Path>) -> Result<Backup>Writes the backup to path whole: beside it first, then renamed once
synced, so that a backup that fails leaves no zip.
BackupBuilder.write_to
pub fn write_to(self, out: impl Write) -> Result<Backup>Writes the backup to out as it is made, for a program that sends it
elsewhere: what out holds of a backup that fails is no backup.
aio::backup::BackupBuilder
pub struct BackupBuilder { /* private fields */ }A backup about to be made, as crate::backup::BackupBuilder builds
one: the files of the program's it takes beside the engines', and
whether it takes the store's encryption key.
write and write_to run blocking on a thread of the store's pool, and
once polled each runs to its end, whether or not anyone still awaits it.
aio::backup::BackupBuilder.include
pub fn include(self, name: &str) -> SelfIncludes a file of the program's, by its path inside the store's
directory, such as secret.key, which a restore puts back where it
was.
aio::backup::BackupBuilder.include_encryption_key
pub fn include_encryption_key(self) -> SelfIncludes the store's encryption key, as it is, which a backup leaves out otherwise: the zip is not encrypted, so a backup with the key opens every value it holds.
aio::backup::BackupBuilder.write
pub fn write(self, path: impl AsRef<Path>) -> impl Future<Output = Result<Backup>> + Send + 'staticWrites the backup to path whole, as
crate::backup::BackupBuilder::write does: beside it first, then
renamed once synced, so that a backup that fails leaves no zip.
aio::backup::BackupBuilder.write_to
pub fn write_to(
self,
out: impl Write + Send + 'static,
) -> impl Future<Output = Result<Backup>> + Send + 'staticWrites the backup to out as it is made, as
crate::backup::BackupBuilder::write_to does, for a program that
sends it elsewhere: out is written on the thread of the store's
pool that makes the backup, and what it holds of a backup that fails
is no backup.