Archive

class py42.modules.archive.ArchiveModule(archive_accessor_manager, archive_client)

Bases: object

A module for getting information about backup archives on storage nodes along with functionality for streaming a file from backup.

get_all_device_restore_history(days, device_id)

Gets all restore jobs from the past given days for the device with the given ID. REST Documentation

Parameters
  • days (int) – Number of days of restore history to retrieve.

  • device_id (int) – The identification number of the device to get restore history for.

Returns

An object that iterates over py42.response.Py42Response objects that each contain a page of restore history.

Return type

generator

get_all_org_restore_history(days, org_id)

Gets all restore jobs from the past given days for the organization with the given ID. REST Documentation

Parameters
  • days (int) – Number of days of restore history to retrieve.

  • org_id (int) – The identification number of the organization to get restore history for.

Returns

An object that iterates over py42.response.Py42Response objects that each contain a page of restore history.

Return type

generator

get_all_user_restore_history(days, user_id)

Gets all restore jobs from the past given days for the user with the given ID. REST Documentation

Parameters
  • days (int) – Number of days of restore history to retrieve.

  • user_id (int) – The identification number of the user to get restore history for.

Returns

An object that iterates over py42.response.Py42Response objects that each contain a page of restore history.

Return type

generator

get_backup_sets(device_guid, destination_guid)

Gets all backup set names/identifiers referring to a single destination for a specific device. Learn more about backup sets.

Parameters
  • device_guid (str) – The GUID of the device to get backup sets for.

  • destination_guid (str) – The GUID of the destination containing the archive to get backup sets for.

Returns

A response containing the backup sets.

Return type

py42.response.Py42Response

stream_from_backup(file_path, device_guid, destination_guid=None, archive_password=None, encryption_key=None)

Streams a file from a backup archive to memory. REST Documentation

Parameters
  • file_path (str) – The path to the file in your archive.

  • device_guid (str) – The GUID of the device the file belongs to.

  • destination_guid (str, optional) – The GUID of the destination that stores the backup of the file. If None, it will use the first destination GUID it finds for your device. ‘destination_guid’ may be useful if the file is missing from one of your destinations or if you want to optimize performance. Defaults to None.

  • archive_password (str, None) – The password for archives that are protected with an additional password. This is only relevant to users with archive key password security. Defaults to None.

  • encryption_key (str, None) – A custom encryption key for decryption an archive’s file contents, necessary for restoring files. This is only relevant to users with custom key archive security. Defaults to None.

Returns

A response containing the streamed content.

Return type

py42.response.Py42Response

Usage example:

stream_response = sdk.archive.stream_from_backup("/full/path/to/file.txt", "1234567890")
with open("/path/to/my/file", 'wb') as f:
    for chunk in stream_response.iter_content(chunk_size=128):
        if chunk:
            f.write(chunk)
update_cold_storage_purge_date(archive_guid, purge_date)

Updates the cold storage purge date for a specified archive. REST Documentation

Parameters
  • archive_guid (str) – The identification number of the archive that should be updated

  • purge_date (str) – The date on which the archive should be purged in yyyy-MM-dd format

Returns

the response from the ColdStorage API.

Return type

py42.response.Py42Response