API¶
runner¶
Runner.
-
dothebackup.runner.
builder
(config, name)[source]¶ Builds a dict of commands.
Parameters: - config (
Dict
[str
,Dict
[str
,Dict
[~KT, ~VT]]]) – YAML config - name (
Optional
[str
]) – Name of a specific job to run
Return type: Dict
[str
,List
[List
[str
]]]Returns: A dict with all commands needed commands
- config (
-
dothebackup.runner.
check_config_keys
(config, key_list)[source]¶ Aborts if keys are not set in config.
Parameters: - config (dict) – Config
- key_list (list) – List of used keys
Return type: None
-
dothebackup.runner.
check_if_already_running
()[source]¶ Aborts if other DoTheBackup process is running.
Return type: None
-
dothebackup.runner.
check_plugin
(name)[source]¶ Aborts and throw an error if plugin is not there as defined as type in config.
Parameters: name (str) – Name of plugin that is defined in the config Return type: None
-
dothebackup.runner.
get_started
(configfile, name, test)[source]¶ The entrypoint for the UI.
This is used to get everything started up. It will read the config, check the keys, build the command dictionary and run them.
Parameters: - configfile (
IO
[AnyStr
]) – The config file - name (
str
) – A name of a specific job - test (
bool
) – Switch for only printing the commands
Return type: None
- configfile (
-
dothebackup.runner.
parse_config
(configfile)[source]¶ Read config file.
Parameters: configfile (_io.TextIOWrapper) – YAML config file Returns: loaded configfile Return type: dict
-
dothebackup.runner.
print_commands
(commands)[source]¶ Prints the commands that would be used.
Parameters: commands ( Dict
[str
,List
[List
[str
]]]) – Command dictionaryReturn type: None
-
dothebackup.runner.
run_commands
(commands, test, log_dir, log_keep)[source]¶ Running the commands.
The actual runner. It will take the commands dictionary and run it one after another. There is also a test key. With this enabled it will only print the commands it would run.
Parameters: - commands (
Dict
[str
,List
[List
[str
]]]) – Commands dictionary - test (
bool
) – If test the commands only will be printed - log_dir (
str
) – Dictionary for logfiles - log_keep (
int
) – How many logs to keep from one job
Return type: None
- commands (
logger¶
Logger.
-
class
dothebackup.logger.
Logger
(log_dir, name, keep)[source]¶ A logger for handling stdout logging.
Parameters: - log_dir (
str
) – Directory to store logfiles in - name (
str
) – Name of the backup job - keep (
int
) – Number of logs to keep
- log_dir (
plugins¶
Plugins.
-
dothebackup.plugins.
load_plugins
()[source]¶ Load plugins from plugin directory.
This function reads the plugs directory and loads all plugins.
Return type: Dict
[str
,Callable
]
utils¶
Utils.
-
dothebackup.utils.
absolutenormpath
(path)[source]¶ Returns a absolute normalized path.
Parameters: path ( str
) – PathReturn type: str
Returns: Absolute path
-
dothebackup.utils.
git_cloned_yet
(path)[source]¶ Returns if path contains a git repository.
Parameters: path ( str
) – A pathReturn type: bool
Returns: If path contains a git repositoy
-
dothebackup.utils.
git_something_to_commit
(path)[source]¶ Returns if path has something to commit.
Parameters: path ( str
) – A pathReturn type: bool
Returns: If path has something to commit
-
dothebackup.utils.
pidfile
()[source]¶ Contextmanager to create a Pidfile for the DoTheBackup process and removes it afterwards.
Return type: Iterator
[None
]