AutoArchive._archiving._core¶
Archiving component internal package.
Modules¶
archiving_component¶
ArchivingComponent class.
-
class
AutoArchive._archiving._core.archiving_component.ArchivingComponent(interfaceAccessor)[source]¶ Bases:
AutoArchive._mainf.icomponent.IComponent,AutoArchive._archiving.iarchiving.IArchivingProvides an interface for working with archives.
During construction it registers itself as
IArchivingcomponent interface tointerfaceAccessor.Several methods of this class requires an archive specification file as the input parameter (usually named
specFile). This file should contain all information required to create the backup. Its format is defined by the standardconfigparsermodule. It has to contain section[Content]and may contain section[Archive]. The[Content]section requires following options to be present:path,include-filesandexclude-files. Optionally,namecan be present. Options in the archive specification file has higher priority than those in the configuration.-
getArchiveInfo(specFile)[source]¶ See:
IArchiving.getArchiveInfo()Warning
This method utilizes the user configuration directory so the option
Options.USER_CONFIG_DIRhas to point to an existing directory.
-
getStoredArchiveInfo(archiveName)[source]¶ See:
IArchiving.getStoredArchiveInfo().Warning
This method utilizes the user configuration directory so the option
Options.USER_CONFIG_DIRhas to point to an existing directory.
-
getStoredArchiveNames()[source]¶ See:
IArchiving.getStoredArchiveNames().Warning
This method utilizes the user configuration directory so the option
Options.USER_CONFIG_DIRhas to point to an existing directory.
-
makeBackup(specFile)[source]¶ Creates the backup based on
specFile.The result can be a file with a full backup or an incremental backup of some particular level. This depends on the archive specification file (
specFile), the configuration (IAppConfig), previous operations with thespecFileand the time. Some of the properties ofArchiveInforeturned by the methodgetArchiveInfo()can be used to determine what the result will be. The path and name of the created file will be assembled as follows: “<Options.DEST_DIR>/<archive_name>[.<backup_level>].<archiver_specific_extension>”.Method uses
IComponentUiinterface to report errors, warnings et al. to the user.Warning
This method utilizes the user configuration directory so the option
Options.USER_CONFIG_DIRhas to point to an existing directory.See also:
IArchiving.makeBackup().
-
purgeStoredArchiveData(archiveName)[source]¶ See:
IArchiving.purgeStoredArchiveData().Warning
This method utilizes the user configuration directory so the option
Options.USER_CONFIG_DIRhas to point to an existing directory.
-
run()[source]¶ See:
IComponent.run().
-
_archiver_manipulator¶
_ArchiverManipulator class.
-
class
AutoArchive._archiving._core._archiver_manipulator._ArchiverManipulator(backupInformationProvider, interfaceAccessor)[source]¶ Bases:
objectPerforms actions with backups.
Uses
IArchiverservices to manipulate with or create backups.Note
backupInformationProvideris not updated by this class.Parameters: - backupInformationProvider – Represents the archive that this instance shall be manipulating with.
- interfaceAccessor (
IInterfaceAccessor) – AnIInterfaceAccessorinstance.
Raises: RuntimeError – If the archiver service could not be created.
-
createBackup()[source]¶ Runs the archiver and creates a backup.
Returns: Path to the created backup.
Return type: strRaises: - RuntimeError – If the backup operation was aborted due to a fatal error.
- OSError – If a system error occurred while making the backup.
-
isOptionSupported(option)[source]¶ Returns
Trueif the passedoptionis supported by the current configuration of this instance.Whether an option is supported or not depends on the archiver type set in the archive specification file that is currently attached.
Parameters: option ( Option) – The option which shall be tested for support.Returns: Trueif the passedoptionis supported;Falseotherwise.Return type: bool
-
saveBackupLevelInfo(backupFilePath)[source]¶ Saves all the information required for backup level restarting to the persistent storage.
Note
This method should be called only once after the backup was created.
Parameters: backupFilePath ( str) – Path to the created backup.
-
classmethod
tryPurgeStoredArchiveData(archiveName, userConfigDir, storage)[source]¶ Deletes all data stored for the archive named
archiveNameif any.See also:
_BackupInformationProvider.getStoredArchiveNames()Parameters: - archiveName (
str) – Name of the archive which data shall be purged. - userConfigDir (
str) – Path to the user configuration directory. - storage (
IStorage) – The application storage.
Returns: Trueif data was purged;Falseotherwise.Return type: boolRaises: - RuntimeError – If the archiver service could not be created.
- OSError – If an error occurred during the operation of removing data from a physical storage.
- archiveName (
_backup_information_provider¶
_BackupInformationProvider class.
-
class
AutoArchive._archiving._core._backup_information_provider._BackupInformationProvider(archiveSpec, interfaceAccessor)[source]¶ Bases:
objectProvides information about backups.
Parameters: - archiveSpec (
_ArchiveSpec) – Archive specification of the backup that this instance will provide information about. - interfaceAccessor (
IInterfaceAccessor) – AnIInterfaceAccessorinstance.
Raises: - RuntimeError – If the archiver service could not be created.
- OSError – If a system error occurred.
-
static
getBackupLevelForBackup(archiveName, userConfigDir)[source]¶ Returns current backup level for the passed
archiveName.Parameters: - archiveName (
str) – Name of the archive for which the backup level shall be returned. - userConfigDir (
str) – Path to the user configuration directory.
Returns: Current backup level for
archiveNameor NoneReturn type: intRaises: - RuntimeError – If the archiver service could not be created.
- OSError – If a system error occurred.
- archiveName (
-
getLastFullRestartDate()[source]¶ Reads the last full restart date from the persistent storage and returns it.
Returns: Date of the last full backup level restart. Return type: datetime.date
-
getLastRestartDate()[source]¶ Reads the last restart date from the persistent storage and returns it.
Returns: Date of the last backup level restart. Return type: datetime.date
-
static
getRestartDate(storageVariable, storagePortion)[source]¶ Reads the date of a backup level restart from storage and returns it.
Parameters: - storageVariable (
str) – Variable that holds the restart date in the persistent storage. - storagePortion (
IStoragePortion) – The persistent storage where the variable is located.
Returns: A backup level restart date.
Return type: datetime.date- storageVariable (
-
classmethod
getStoredArchiveNames(userConfigDir, storage)[source]¶ Returns iterable of archive names which has some data stored in a persistent storage.
Persistent storages from which archive names are retrieved are specific to the concrete archiver service. A typical storage used by archivers is the application storage (
IStorage).Parameters: - userConfigDir (
str) – Path to the user configuration directory. - storage (
IStorage) – The application storage.
Returns: Set of archive names.
Return type: set<str>Raises: RuntimeError – If the archiver service could not be created.
- userConfigDir (
-
archiveSpec¶ Gets the archive specification that corresponds to the backup about which this instance provides information.
Return type: _ArchiveSpec
-
currentBackupLevel¶ Gets the current backup level or
None.Return type: int
-
nextBackupLevel¶ Gets the backup level that would be created if the backup creation was triggered.
Return type: int
-
restartLevel¶ Gets a backup level to which a next restart would be done.
Return type: int
-
restartReason¶ Gets the reason for upcoming backup level restart.
Return type: BackupLevelRestartReasons
- archiveSpec (
_archiving_constants¶
_ArchiverMaps and _RestartStorageVariables classes.
-
class
AutoArchive._archiving._core._archiving_constants._ArchiverMaps[source]¶ Bases:
objectMappings which involves archiver types.
-
ARCHIVER_TYPE_TO_SERVICE_MAP= {0: 1, 1: 1, 2: 1, 3: 1, 4: 0, 5: 0, 6: 0}¶
-
-
class
AutoArchive._archiving._core._archiving_constants._RestartStorageVariables[source]¶ Bases:
objectNames of storage variables for backup level restarting.
-
BACKUP_SIZE= 'archiving-size-level'¶
-
LAST_FULL_RESTART= 'archiving-last-full-restart'¶
-
LAST_RESTART= 'archiving-last-restart'¶
-
RESTART_COUNT= 'archiving-restart-count'¶
-
_archive_spec¶
_ArchiveSpec class.
-
class
AutoArchive._archiving._core._archive_spec._ArchiveSpec(specFile, configuration, componentUi=None)[source]¶ Bases:
AutoArchive._configuration.configuration_base.ConfigurationBaseThe archive specification.
Contains all information needed to create the backup such as the name, list of files which shall be included into the backup, list of files to exclude, etc. These values can be configured in the archive specification file (
specFile) or in the general configuration such as command line or configuration files. Options that can be read from this class are defined as static attributes of_ArchiveSpecOptionsandOptions. If an option is not defined in the archive specification file it is read fromconfiguration.The instance is fully populated during construction.
Parameters: - specFile (
str) – Archive specification file name (the “.aa file”). - configuration (
IConfiguration) – The application’s configuration. - componentUi (
IComponentUi) – The application’s UI interface. IfNonethen messages about non-accessible files or other errors during processing of included and excluded file lists will not be shown.
Raises: - IOError – If
specFilecan not be opened. - LookupError – If a section or an option is missing in
specFile. - SyntaxError – If
specFilecan not be parsed. - KeyError – If an invalid (unsupported) section or option is found in the archive specification file.
- ValueError – If option’s value is not correct.
- specFile (
-
class
AutoArchive._archiving._core._archive_spec._ArchiveSpecOptions[source]¶ Bases:
objectConstants for options used specifically in the archive specification file.
These constants should be used to access options in
_ArchiveSpec.Note
It is not allowed to change values of these constants.
-
EXCLUDE_FILES= <Option exclude-files of type <class 'str'>>¶
-
INCLUDE_FILES= <Option include-files of type <class 'str'>>¶
-
NAME= <Option name of type <class 'str'>>¶
-
PATH= <Option path of type path>¶
-