Skip to main content

nodedb_types/backup_envelope/
database.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! A database backup: one encrypted envelope whose sections are whole tenant
4//! envelopes.
5//!
6//! The outer envelope's `meta.tenant_id` is [`DATABASE_BACKUP_TENANT`]. Its
7//! first section, [`SECTION_ORIGIN_DATABASE_MANIFEST`], names the database and
8//! lists its tenants. Every other section's `origin_node_id` is a tenant id,
9//! and its body is that tenant's envelope, covering this database only. The
10//! outer authentication tag covers the whole set, so a dropped tenant fails
11//! the parse.
12
13/// `meta.tenant_id` of a database backup's outer envelope.
14pub const DATABASE_BACKUP_TENANT: u64 = u64::MAX;
15
16/// Section carrying a database backup's [`DatabaseBackupManifest`].
17pub const SECTION_ORIGIN_DATABASE_MANIFEST: u64 = 0xFFFF_FFFF_FFFF_FFE0;
18
19/// What a database backup holds.
20#[derive(Debug, Clone, PartialEq, Eq, zerompk::ToMessagePack, zerompk::FromMessagePack)]
21pub struct DatabaseBackupManifest {
22    /// Name of the backed-up database. A restore targets the same name.
23    pub database: String,
24    /// HLC wall time, in nanoseconds, of the one consistent cut every tenant
25    /// was captured at. Every row in the backup committed at or below it.
26    pub cut_hlc: u64,
27    /// Every tenant with a section, in section order.
28    pub tenants: Vec<u64>,
29}