genvid.toolbox.Backup
- class genvid.toolbox.Backup
Bases:
object
API to create backup archives and restore data from them.
The idea is to subclass this base class with different “strategies” to backup and restore data. Then, as long as all the strategies are compatible, you can use the methods from this class to backup / restore all everything easily.
- backup(archive: ZipFile, obj)
Save the relevant state in a ZIP archive.
Objects subclassing
Backup
are responsible for populating a ZIP archive with all the necessary data they need to restore.- Parameters:
archive – ZIP archive for storing recovery data.
obj – Instance of the object whose state is to be backupd.
- restore(archive: ZipFile, obj)
Recover state from the data backupd in the backup ZIP archive.
Objects subclassing
Backup
should be able to restore all relevant states from the data that was added withbackup()
.- Parameters:
archive – ZIP archive containing the recovery data.
obj – Instance of the object whose state is to be restored.
- static backup_all(strategies: Iterable[Backup], path: str, obj)
Allow to easily backup states using multiple strategies.
- Parameters:
path – Path to the ZIP archive destination (it will be created or overridden).
obj – Instance of the object containing the states to backup.
Warning
It is important to refer to the documentation of each backup strategy to make sure the
obj
passed as parameter is compatible with each of them. Additionally, a logger should be present on theobj
for diagnostics.
- static restore_all(strategies: Iterable[Backup], path: str, obj)
Allow to easily restore states using multiple strategies.
- Parameters:
path – Path to the ZIP archive containing the backup data.
obj – Instance of the object which will receive the restored states.
Warning
It is important to refer to the documentation of each restore strategy to make sure the
obj
passed as parameter is compatible with each of them. Additionally, a logger should be present on theobj
for diagnostics.
- class backup.Backup
Implementation of
genvid.toolbox.Backup