Provides the core functionality of the application. Executes an archiver and creates a backup based on provided archive specification file and configuration. It also allows to read various information about configured and stored archives. It requires archiver service (ArchiverServiceIdentification) for the backup creation.
Bases: builtins.object
Takes care of executing user actions - application main use cases.
Parameters: |
|
---|
Executes create backup(s) action.
Takes selectedArchiveSpecs and for each it creates a backup. If selectedArchiveSpecs is empty or Options.ALL is set to True then backups for all knows archives (typically all archive specification files in Options.ARCHIVE_SPECS_DIR directory) plus those in selectedArchiveSpecs are created.
Parameters: | selectedArchiveSpecs (Sequence<ArchiveSpecInfo>) – archive specification files for which backups shall be created. |
---|
Lists information about selected and orphaned archives to standard output.
Similarly to executeCreateAction() archives in selectedArchiveSpecs are listed. If it is empty or Options.ALL is True then all archives plus selected are listed. Orphaned archives are always listed.
List of orphaned archives is obtained by following operation: from the list of stored archives is subtracted the unique list of valid selected archives and valid configured archives.
Output has two possible formats depending on the Options.VERBOSE option.
Parameters: | selectedArchiveSpecs (Sequence<ArchiveSpecInfo>) – archive specification files which shall be listed. |
---|
Removes all stored information about specified orphaned archives.
If selectedArchiveSpecs is empty or Options.ALL is True then all orphaned archives are processed.
Parameters: | selectedArchiveSpecs (Sequence<ArchiveSpecInfo>) – archive specification files which shall be purged. |
---|
ArchiveSpecInfo and ConfigConstants.
Bases: builtins.tuple
Holds information about an archive specification file; its name and full path.
Alias for field number 0
Alias for field number 1
Bases: builtins.object
Configuration related constants.
Extension of archive specification files.
_Archiving class.
Bases: builtins.object
Provides means for working with archives.
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 standard configparser module. It has to contain section [Content] and may contain section [Archive]. The [Content] section requires following options to be present: path, include-files and exclude-files. Optionally, name can be present. Options in the archive specification file has higher priority than those in the configuration.
Parameters: |
|
---|
Returns names of configured archives from valid only archive specification files passed in specFiles.
Parameters: | specFiles (Iterable<str>) – Paths to archive specification files that shall be validated and from which the names shall be retrieved. |
---|---|
Returns: | Iterable of names of validly configured archives. |
Return type: | Iterable<str> |
Returns information about archive represented by the specFile parameter.
Warning
This method utilizes the user configuration directory so the option Options.USER_CONFIG_DIR has to point to an existing directory.
Parameters: | specFile (str) – Path to the archive specification file. |
---|---|
Returns: | Information about an archive or None. |
Return type: | _ArchiveInfo |
Iterable of all known archive specification files.
Returns: | Iterable of archive specification files information. |
---|---|
Return type: | Iterable<ArchiveSpecInfo> |
Raises RuntimeError: | |
If list of archive specification can not be obtained. |
Returns information about an archive from stored data.
Unlike in the getArchiveInfo() method the information is not read from the archive specification file but from other stored data about the archive created by the component in previous runs. Such data can be fetched for example from application storage (IStorage) or other sources specific to the archiver. It is expected that the large portion of data will be missing in the returned information.
Warning
This method utilizes the user configuration directory so the option Options.USER_CONFIG_DIR has to point to an existing directory.
See also: getStoredArchiveNames()
Parameters: | archiveName (str) – Name of the archive which information shall be returned. |
---|---|
Returns: | Information about an archive or None if no data for the archive was found. |
Return type: | _ArchiveInfo |
Returns iterable of archive names which has some data stored in a persistent storage.
Warning
This method utilizes the user configuration directory so the option Options.USER_CONFIG_DIR has to point to an existing directory.
See also: getStoredArchiveInfo()
Returns: | Iterable of archive names. |
---|---|
Return type: | Iterable<str> |
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 (IConfiguration), previous operations with the specFile and the time. Some of the properties of _ArchiveInfo returned by the method getArchiveInfo() 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 CmdlineUi-like interface to report errors, warnings et al. to the user.
Warning
This method utilizes the user configuration directory so the option Options.USER_CONFIG_DIR has to point to an existing directory.
See also: IArchiving.makeBackup().
Parameters: | specFile (str) – Path to the archive specification file. |
---|---|
Raises ValueError: | |
If the desired archiver type is not supported. |
Deletes all data stored for the archive named archiveName.
Warning
This method utilizes the user configuration directory so the option Options.USER_CONFIG_DIR has to point to an existing directory.
See also: getStoredArchiveInfo()
Parameters: | archiveName (str) – Name of the archive which data shall be purged. |
---|---|
Raises: |
|
_BackupInformationProvider class.
Bases: builtins.object
Provides information about backups.
Parameters: |
|
---|---|
Raises: |
|
Returns current backup level for the passed archiveName.
Parameters: |
|
---|---|
Returns: | Current backup level for archiveName or None |
Return type: | int |
Raises: |
|
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 |
Reads the last restart date from the persistent storage and returns it.
Returns: | Date of the last backup level restart. |
---|---|
Return type: | datetime.date |
Reads the date of a backup level restart from storage and returns it.
Parameters: |
|
---|---|
Returns: | A backup level restart date. |
Return type: | datetime.date |
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: |
|
---|---|
Returns: | Set of archive names. |
Return type: | set<str> |
Raises RuntimeError: | |
If the archiver service could not be created. |
Gets the archive specification that corresponds to the backup about which this instance provides information.
Return type: | _ArchiveSpec |
---|
Gets the backup level that would be created if the backup creation was triggered.
Return type: | int |
---|
Gets a backup level to which a next restart would be done.
Return type: | int |
---|
_CommandExecutor class.
_ArchiverMaps and _RestartStorageVariables classes.
Bases: builtins.object
Mappings which involves archiver types.
Bases: builtins.object
Names of storage variables for backup level restarting.
_ArchiveSpec class.
Bases: AutoArchive._infrastructure.configuration.configuration_base.ConfigurationBase
The 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 _ArchiveSpecOptions and Options. If an option is not defined in the archive specification file it is read from configuration.
The instance is fully populated during construction.
Parameters: |
|
---|---|
Raises: |
|
Bases: builtins.object
Constants 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.
Files and directories that will be excluded from the backup (frozenset<str>). Note that frozenset<str> is not supported by OptionsUtils.strToOptionType(); it is not used while populating this option. Guaranteed to be defined.
Files and directories that will be included in the backup (frozenset<str>). Note that frozenset<str> is not supported by OptionsUtils.strToOptionType(); it is not used while populating this option. Guaranteed to be defined.
Archive name (str). Guaranteed to be defined.
Path to the base directory for INCLUDE_FILES, EXCLUDE_FILES (SpecialOptionTypes.PATH). Guaranteed to be defined.
_BackupLevelRestartReasons enum and _ArchiveInfo class.
Bases: builtins.object
Information about an archive.
Note
Class should be instantiated by calling the _Archiving.getArchiveInfo() or _Archiving.getStoredArchiveInfo() factory methods.
Gets the archiver type for this archive.
Note
Value is guaranteed to be non-None.
Return type: | ArchiverTypes |
---|
Gets the current backup level.
Note
Will be None if the archive is not incremental or used archiverType does not support incremental archiving.
Note
For archiver types that supports incremental archiving, whether the return value will be None or not does not depend on the current incremental value. If the archive was configured and created as incremental previously then the backup level will be defined even if the current incremental value would be False and vice versa.
Return type: | int |
---|
Gets the archive’s destination directory.
Note
Value is guaranteed to be non-None.
Return type: | str |
---|
Gets the number of days after which the backup level should be restarted to level 0.
Note
Will be None if the archiverType does not support incremental archiving or if no value is defined for Options.FULL_RESTART_AFTER_AGE.
Return type: | int |
---|
Gets the number of restarts after which the backup level will be restarted to 0.
Note
Will be None if the archiverType does not support incremental archiving or if no value is defined for Options.FULL_RESTART_AFTER_COUNT.
Return type: | int |
---|
Gets the status of incremental archiving activation.
Note
Will be None if the archiverType does not support incremental archiving.
Return type: | bool |
---|
Gets the date when the last backup level restart to level 0 occurred.
Note
Will be None if the archiverType does not support incremental archiving or if restarting was not enabled for the archive in the past.
Return type: | datetime.date |
---|
Gets the date when the last backup level restart occurred.
Note
Will be None if the archiverType does not support incremental archiving or if restarting was not enabled for the archive in the past.
Return type: | datetime.date |
---|
Gets the next backup level.
See also backupLevel.
Note
Will be None if the archive is not incremental or used archiverType does not support incremental archiving.
Return type: | int |
---|
Gets the path to the archive’s root.
Note
Will be None if the archive’s root can not be retrieved.
Return type: | str |
---|
Gets the number of days after which the backup level should be restarted.
Note
Will be None if the archiverType does not support incremental archiving or if no value is defined for Options.RESTART_AFTER_AGE.
Return type: | int |
---|
Gets the maximal backup level; after it is reached it will be restarted to a lower value.
Note
Will be None if the archiverType does not support incremental archiving.
Return type: | int |
---|
Gets the number of backup level restarts already performed.
Note
Will be None if the archiverType does not support incremental archiving or if restarting was not enabled for the archive in the past.
Return type: | int |
---|
Gets a backup level to which a next restart would be done.
Note
Will be None if the archiverType does not support incremental archiving.
Return type: | int |
---|
Gets the reason for the upcoming backup level restart.
Note
Will be None if the archiverType does not support incremental archiving or the restart reason can not be determined.
Return type: | _BackupLevelRestartReasons |
---|
Gets the status of backup level restarting activation.
Note
Will be None if the archiverType does not support incremental archiving.
Return type: | bool |
---|