Skip to content

Hub Snapshots #565

@jortel

Description

@jortel

Use Cases

Note: all use cases can performed using API or UI.

As a user, I want to backup the inventory.

As a user, I want to restore a specific snapshot of the inventory.

As a user, I can list, create and delete snapshots.

As a user, I want to demo using a (choice of) snapshots of the inventory.

Overview

A Hub snapshot contains the DB and bucket/file data. They can be used to prime an instance for demos, backup/restore and reverting to a snapshot in time.

  • Created
  • Listed
  • Exported
  • Imported
  • Deployed
  • Deleted

Snapshot Anatomy (tarball):

  • /snapshot.yaml - manifest YAML file about the snapshot.
    • name: The name of the snapshot.
    • key: (optional) The encryption key (encrypted using a password).
  • /hub.db - The sqlite3 DB file.
  • /bucket - The bucket tree.

Snapshots stored on the /snapshot PV.

Workflows:

List

route: GET /snapshots
returns: A list of created or uploaded snapshots. (Listing of name: found in manifests).

Export

route: POST /snapshots/export
body: A password used to encrypt the encryption key.
returns: streamed snapshot (tarball).

Create

route: POST /snapshots/:name
actions:

  • Create /snapshot/uuid/snapshot.yaml (with name).
  • Create /snapshot/uuid/snapshot.tar.gz

Import

route: POST /snapshots/import/:name
body: multi-part file upload of a tarball and the password used to encrypt the encryption key.
action:

  • Store the uploaded in snapshot (tarball) in /snapshot/uuid
  • Extract /snapshot.yaml and decrypt the key using the password.
  • Encrypt key in /snapshot.yaml using the (local) encryption key and update the extracted file.

Deploy

route: POST /snapshot/deploy/:name
action: Create a symlink /snapshot/deploy => the snapshot (directory) to be deployed.

Deploy Flow in Hub main.

  1. Detect /snapshot/deploy
  2. Extract the tarball
  3. Update Settings.Hub.DB.Path = /snapshot/deploy/hub.db.
  4. Update Settings.Hub.Bucket.Path = /snapshot/deploy/bucket
  5. Run migration
  6. Re-Encrypt identities using the key in /snapshot/deploy/snapshot.yaml and the (local) encryption key.
  7. Replace the Live hub.db and /bucket (tree) snapshot.
  8. Delete (unlink) /snapshot/deploy.
  9. Reload Settings.Hub.
  10. Start services.

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.priority/normalHigher priority than priority/minor. Nice to have.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions