pocketenv/backup

Create, list, and restore backups of a sandbox directory.

Backups let you snapshot a directory inside a running sandbox and restore it later. All three operations are scoped to a ConnectedSandbox.

Types

A point-in-time snapshot of a sandbox directory.

pub type Backup {
  Backup(
    id: String,
    directory: String,
    description: option.Option(String),
    expires_at: option.Option(String),
    created_at: String,
  )
}

Constructors

  • Backup(
      id: String,
      directory: String,
      description: option.Option(String),
      expires_at: option.Option(String),
      created_at: String,
    )

Values

pub fn backup_decoder() -> decode.Decoder(Backup)

JSON decoder for Backup.

pub fn create(
  sb: sandbox.ConnectedSandbox,
  directory: String,
  description: option.Option(String),
  ttl: option.Option(Int),
) -> Result(Nil, pocketenv.PocketenvError)

Creates a backup of directory inside the sandbox. Optionally set a human-readable description and a time-to-live ttl (in seconds) after which the backup is automatically deleted.

Example

let assert Ok(Nil) = sb |> backup.create("/app", Some("pre-deploy"), None)
pub fn list(
  sb: sandbox.ConnectedSandbox,
) -> Result(List(Backup), pocketenv.PocketenvError)

Lists all backups associated with the sandbox.

Example

let assert Ok(backups) = sb |> backup.list()
pub fn restore(
  sb: sandbox.ConnectedSandbox,
  backup_id: String,
) -> Result(Nil, pocketenv.PocketenvError)

Restores the backup identified by backup_id into the sandbox.

Example

let assert Ok(Nil) = sb |> backup.restore("backup-abc123")
Search Document