amnesia v0.2.8 Amnesia.Backup behaviour

This module provides a behavior to implement a backup module and helpers to use backups.

Link to this section Summary

Functions

Create a checkpoint, see mnesia:activate_checkpoint. It's important to backup the metadata table, to avoid bugs when restoring the database.

Create a checkpoint with the given name, see mnesia:activate_checkpoint.

Install a fallback with the default backup module, see mnesia:install_fallback.

Install a fallback with the given backup module, see mnesia:install_fallback.

Install a fallback with the given backup module and options, see mnesia:install_fallback.

Restore a backup, see mnesia:restore.

Restore a backup with the given module, see mnesia:restore.

Start a backup with the default backup module, see mnesia:backup.

Start a backup of a given checkpoint, see mnesia:backup_checkpoint.

Traverse a backup, see mnesia:traverse_backup.

Traverse a backup with custom backup modules, see mnesia:traverse_backup.

Uninstall a fallback, see mnesia:uninstall_fallback.

Uninstall a fallback, see mnesia:uninstall_fallback.

Uninstall a fallback, see mnesia:uninstall_fallback.

Callbacks

Close the backup if the backup is interrupted.

Close the backup.

Commit the write to the backup.

Open the backup for reading.

Open the backup for writing.

Read terms from the backup.

Write the given terms to the backup.

Link to this section Types

Link to this type

i()

i() :: {:module, atom()} | {:scope, :global | :local} | {:directory, String.t()}
Link to this type

o()

o() :: {:ok, any()} | {:error, any()}
Link to this type

r()

r() :: [
  {:module, atom()}
  | {:keep | :skip | :clear | :recreate, atom() | [atom()]}
  | {:default, :keep | :skip | :clear | :recreate}
]

Link to this section Functions

Link to this function

checkpoint(options)

checkpoint(Keyword.t()) :: {:ok, any(), [node()]} | {:error, any()}

Create a checkpoint, see mnesia:activate_checkpoint. It's important to backup the metadata table, to avoid bugs when restoring the database.

Example to backup on a file called "backup" the table Account as well the metadata table:

Amnesia.Backup.checkpoint(%{
  name: 'backup',
  max: [Database.Account, Database]
})
Link to this function

checkpoint(name, options)

checkpoint(any(), Keyword.t()) :: {:ok, any(), [node()]} | {:error, any()}

Create a checkpoint with the given name, see mnesia:activate_checkpoint.

Link to this function

install(data)

install(any()) :: :ok | {:error, any()}
install(atom() | any()) :: :ok | {:error, any()}

Install a fallback with the default backup module, see mnesia:install_fallback.

Link to this function

install(module, data)

Install a fallback with the given backup module, see mnesia:install_fallback.

Link to this function

install(module, data, options)

install(atom(), any(), i()) :: :ok | {:error, any()}

Install a fallback with the given backup module and options, see mnesia:install_fallback.

Link to this function

restore(data, options)

restore(any(), r()) :: [atom()] | {:error, any()}

Restore a backup, see mnesia:restore.

Link to this function

restore(module, data, options)

restore(atom(), any(), r()) :: {:atomic, [atom()]} | {:aborted, any()}

Restore a backup with the given module, see mnesia:restore.

Link to this function

start(data)

start(any()) :: :ok | {:error, any()}

Start a backup with the default backup module, see mnesia:backup.

Link to this function

start(name, data)

start(any(), any()) :: :ok | {:error, any()}

Start a backup of a given checkpoint, see mnesia:backup_checkpoint.

Link to this function

traverse(source, target, acc, fun)

traverse(any(), any(), any(), ([tuple()], any() -> any())) ::
  {:ok, any()} | {:error, any()}

Traverse a backup, see mnesia:traverse_backup.

Link to this function

traverse(source, source_data, target, target_data, acc, fun)

traverse(atom(), any(), atom(), any(), any(), ([tuple()], any() -> any())) ::
  {:ok, any()} | {:error, any()}

Traverse a backup with custom backup modules, see mnesia:traverse_backup.

Link to this function

uninstall()

uninstall() :: :ok | {:error, any()}

Uninstall a fallback, see mnesia:uninstall_fallback.

Link to this function

uninstall(options)

uninstall(i()) :: :ok | {:error, any()}

Uninstall a fallback, see mnesia:uninstall_fallback.

Link to this function

uninstall(module, options)

uninstall(atom(), i()) :: :ok | {:error, any()}

Uninstall a fallback, see mnesia:uninstall_fallback.

Link to this section Callbacks

Link to this callback

abort_write(any)

abort_write(any()) :: o()

Close the backup if the backup is interrupted.

Link to this callback

close_read(any)

close_read(any()) :: o()

Close the backup.

Link to this callback

commit_write(any)

commit_write(any()) :: o()

Commit the write to the backup.

Link to this callback

open_read(any)

open_read(any()) :: o()

Open the backup for reading.

Link to this callback

open_write(any)

open_write(any()) :: o()

Open the backup for writing.

Link to this callback

read(any)

read(any()) :: {:ok, any(), [any()]} | {:error, any()}

Read terms from the backup.

Link to this callback

write(any, list)

write(any(), [any()]) :: o()

Write the given terms to the backup.