Skip to main content

Module volume_backup

Module volume_backup 

Source
Expand description

Snapshots, backups and staged restores of an org’s named volumes: an app’s <app>_<NAME>, a database’s data, a workspace’s home. Generic over “a custom volume in the org’s incus project”; crate::volume is the raw incus helper underneath.

  • Snapshots (VolumeBackups::snapshot): incus volume snapshots, on a cron schedule (auto-<stamp>, the newest keep kept) or now (manual-<stamp> or a given name, kept until deleted).
  • Backups go through crate::backup: a backup whose source is a volume exports a snapshot of it (export) to the org’s S3 destination, so it is listed, run, retained and logged beside the database backups.
  • The pre-snapshot hook (hook) runs before every snapshot and every backup’s snapshot.
  • Restores are staged (restore): into a new volume, mounted at /restore/<stamp> in the instance, never over the live volume.

On disk: <org root>/volumes/<volume>/volume.json (settings and the scheduler’s anchor) and runs/ (snapshot runs and their logs). Staged restores are described by user.isb.restore-* keys on the volumes themselves; their runs are the org’s restore runs.

Re-exports§

pub use model::VolumeRecord;
pub use model::VolumeSettings;

Modules§

export
A volume backup’s run, for crate::backup: hook, snapshot, a temporary volume copied from the snapshot, incus’ export of it (uncompressed tar) compressed and streamed to the bucket, then the temporary volume, the export and the snapshot deleted.
hook
The pre-snapshot hook: before isb snapshots a volume, each running instance using it runs its executable /etc/isb/pre-snapshot (if it has one), as root, with a timeout, so an image can make its own state consistent first (a SQLite checkpoint, a flushed session file). Its output goes to the run’s log. A failure is reported; it stops the snapshot only when the volume’s settings say hook_required.
incus
The incus calls volume snapshots, exports and staged restores need, on a client already scoped to the org’s project.
model
The pure parts: a volume’s settings, and the names isb gives snapshots, staged restores and backup objects (and reads back for retention).
restore
Staged restores: a snapshot or a backup restores into a NEW volume, <volume>-restore-<stamp>, mounted at /restore/<stamp> in the instance that uses the volume (left detached when it is stopped), for its owner to diff and copy back what they want. The live volume is never written: a second writer over a live home is how work is lost.

Structs§

VolumeBackups
Every org’s volume snapshots and staged restores.

Enums§

SnapshotName
What a snapshot is called.

Functions§

allow_snapshots
Org projects made before isb took snapshots block them (restricted.snapshots, restricted.backups); allow them, as isb org create now does. Only isb reaches an org’s project, so this lets isb, not the org’s instances, snapshot and export.
load_settings
A volume’s settings (the defaults when none are stored).
org_pool
The org’s pool for named volumes and a client in its project.
pre_snapshot
Run the pre-snapshot hook in every running instance using the volume. what: why (snapshot, backup) and the snapshot’s name.
settings_path
The settings file of a volume.