Backup

class activelogic.Backup

This is the resource that governs the backup management of an ActiveLogic system.

async Backup.list(cls)

Generic list function for all kind of data that belongs to this resource.

Parameters:

cls – Object type that determines what kind of data to get.

Returns:

A list of given dataclass type.

Raises:
  • ValueError – Invalid dataclass type.

  • PLDBNewDataCommitted – Conflict with new data committed by an other session.

The following data can be listed from this resource:

  • BackupFile: Lists current status of all resources.

>>> b.list(BackupFile)
[BackupFile(name='20210622-04.48.plb', size=10394934), BackupFile(name='20210622-01.14.plb', size=10394934)...]
class activelogic.BackupFile

Object that represents a backup file.

Parameters:
  • name (str) – Name of the backup.

  • size (int) – Size of the backup in bytes.

async Backup.create_new(name='', resource_name=None)

Creates a new backup.

Parameters:
  • name (str) – Name of the backup to be created. A name is generated automatically if no value is set. (‘20210622-04.48.plb’)

  • resource_name (str) – Name of the resource to be included. All resources are included if no value is set.

Returns:

Name of the backup created.

Return type:

str

>>> b = conn.backup()
>>> b.create_new(resource_name='System Diagnostics')
20210622-04.48.plb
async Backup.restore(name, resource_name=None)

Restores a backup.

Parameters:
  • name (str) – Name of the backup to be restored.

  • resource_name (Resource or int) – Name of resource to be restored. All resources are restored if no value is set.

>>> b = conn.backup()
>>> b.restore(name='20210622-04.48.plb', resource_name='System Diagnostics')
async Backup.remove(name)

Removes a backup.

Parameters:

name (str) – Name of the backup to be removed.

>>> b = conn.backup()
>>> b.remove('20210622-04.48.plb')
async Backup.download(backup_name, *, ofile_obj=None, dest_path=None)

Download a specific file. The file to which the downloaded data is to be written to can be either a file object opened in binary mode or the path of the file to write to.

Parameters:
  • backup_name (str) – The name of the backup to be downloaded.

  • ofile_obj (python file object) – The python file object of the file to which the downloaded data is written to.

  • dest_path (str or pathlib.Path) – The path of the file to which the downloaded data is written to.

Raises:
  • TypeError – backup_name must be of str type

  • TypeError – ofile_obj must be a file object

  • TypeError – ofile_obj must be writable

  • TypeError – dest_path must be an instance of str or pathlib.Path

  • TypeError – One of ofile_obj, dest_path must be provided

  • TypeError – Either one of ofile_obj, dest_path must be provided but not both

  • TypeError – ofile_obj must be opened in binary mode to download text/binary files.

The file object ofile_obj must be opened in binary writable mode to download text/binary files.

>>> b = conn.backup()
>>> b.download('20210622-04.48.plb', dest_path='/home/user/downloaded_backups/newbackup')
>>> b = conn.backup()
>>> with open('testfile', 'wb+') as testfile:
...    b.download('20210622-04.48.plb', ofile_obj=testfile)
>>> b.download('20210622-04.48.plb', dest_path='temp_file')

BytesIO objects could also be used to download files.

>>> f = io.BytesIO()
>>> b.download('20210622-04.48.plb', ofile_obj=f)
>>> f.close()
async Backup.upload(backup_name, *, ifile_obj=None, in_path=None)

Upload a specific file. The file from which data to be uploaded is read from can be specified with either a file object opened in binary mode or path of the input file.

Parameters:
  • backup_name (str) – The name of the the backup to be uploaded.

  • ifile_obj (python file object) – The file object of the input file to be to be uploaded.

  • in_path (str or pathlib.Path) – The path of the file from which data is to be read for upload.

Raises:
  • TypeError – backup_name must be of str type

  • TypeError – in_path must an instance of type str or pathlib.Path

  • TypeError – One of ifile_obj, in_path must be provided

  • TypeError – Either one of ifile_obj, in_path must be provided but not both

  • TypeError – ifile_obj must be a non-None python file object

  • TypeError – ifile_obj must be a readable file

  • TypeError – ifile_obj must be opened in binary mode

  • TypeError – Input file must be a non-empty file

The input file object must be opened in binary mode before calling this method so as to be to upload both text and binary files.

>>> b = conn.backup()
>>> with open('testfile', 'rb') as testfile:
...     b.upload('uploaded_backup.plb', ifile_obj=testfile)
>>> b.upload('uploaded_backup.plb', in_path='test_path')