libioc.ResourceBackup module

ioc Resource extension that managed exporting and importing backups.

class libioc.ResourceBackup.Format[source]

Bases: enum.Enum

Enum of the backup formats.

DIRECTORY = '2'
TAR = '1'
class libioc.ResourceBackup.LaunchableResourceBackup(resource)[source]

Bases: object

Create and restore backups of a LaunchableResource.

It is only possible to run one concurrent backup operation because this instance uses a global temp directory that is deleted when the lock is removed. In fact the existence of a temp directory indicates the locked state.

export(destination, standalone=None, recursive=False, backup_format=<Format.TAR: '1'>, event_scope=None)[source]

Export the resource.

Resource exports contain the jails configuration and differing files between the jails root dataset and its release. Other datasets in the jails dataset are snapshotted and attached to the export entirely.

Parameters
  • destination (str) – The resource is exported to this location as archive file.

  • standalone (bool) – The default depends on whether the resource is forked from a release or not. If there is a origin release, the export will contain the changed files relative to the release. Enabling this option will enforce ZFS dataset exports instead of rsync compare-dest diffs. Standalone exports will cause duplicated data on the importing host, but are independent of any release.

  • recursive (bool) – Includes snapshots of all exported ZFS datasets.

Return type

Generator[IocEvent, None, None]

property full_snapshot_name

Return the dataset name with the snapshot name.

Return type

str

property locked

Return True when a temporary directory exists.

Return type

bool

property logger

Return the resources logger instance.

Return type

Logger

restore(source, event_scope=None)[source]

Import a resource from an archive.

Resource archives created with libiocage backup export can be restored on any host. When importing a basejail the linked release needs to exist on the host.

Parameters

source (str) – The path to the exported archive file (tar.gz)

Return type

Generator[IocEvent, None, None]

property snapshot_name

Return the snapshot_name that was chosen when locking.

Return type

str

property work_dir

Return the absolute path to the current temporary directory.

Return type

str

property zfs

Return the resources ZFS instance.

Return type

ZFS