From 6a6cfa4e02ff65eb67a6f4efefce8dac87c932d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radoslav=20Bod=C3=B3?= <bodik@cesnet.cz> Date: Mon, 15 Apr 2024 13:00:35 +0200 Subject: [PATCH] general: config reference documentation --- README.md | 4 ++++ rwm.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ee52806..d3d1c57 100644 --- a/README.md +++ b/README.md @@ -60,12 +60,16 @@ somewhere - if I only knew.* ## Usage ### Install + ``` git clone https://gitlab.cesnet.cz/radoslav_bodo/rwm.git /opt/rwm cd /opt/rwm make install ``` +Configuration file uses YAML format, see `examples/` for basic use-cases or +`rwm.RWMConfig` autodoc for full reference. + ### RWM: simple backups diff --git a/rwm.py b/rwm.py index 0cd68ce..84a4de5 100755 --- a/rwm.py +++ b/rwm.py @@ -68,20 +68,32 @@ def size_fmt(num): return f'{num:0.1f} YiB' -class BackupConfig(BaseModel): - """backup config model""" +class RWMConfig(BaseModel): + """Main configuration for RWM. Configuration file format is YAML. - model_config = ConfigDict(extra='forbid') + Attributes: + s3_endpoint_url: + REQUIRED. The endpoint URL for S3. - filesdirs: List[str] - excludes: Optional[List[str]] = [] - extras: Optional[List[str]] = [] - prerun: Optional[List[str]] = [] - postrun: Optional[List[str]] = [] + s3_access_key: + REQUIRED. Access key for S3. + s3_secret_key: + REQUIRED. Secret key for S3. -class RWMConfig(BaseModel): - """main config model""" + restic_bucket: + Bucket for Restic backup repository. + + restic_password: + Password for Restic backup repository. + + backups: + Dictionary containing named backup configurations. + + retention: + Dictionary containing retention policies for Restic repository. + Keys and values corresponds to a `restic forget` command `--keep*` options without leading dashes. + """ model_config = ConfigDict(extra='forbid') @@ -94,6 +106,35 @@ class RWMConfig(BaseModel): retention: Dict[str, str] = {} +class BackupConfig(BaseModel): + """Configuration for backup operations. + + Attributes: + filesdirs: + REQUIRED. List of files and directories to be backed up. + + excludes: + List of patterns for `--exclude` options for `restic backup` commmand. Defaults to an empty list. + + extras: + Additional options for the `restic backup` commmand. Defaults to an empty list. + + prerun: + List of shell commands to execute before backup. Defaults to an empty list. + + postrun: + List of shell commands to execute after backup. Defaults to an empty list. + """ + + model_config = ConfigDict(extra='forbid') + + filesdirs: List[str] + excludes: List[str] = [] + extras: List[str] = [] + prerun: List[str] = [] + postrun: List[str] = [] + + class RwmJSONEncoder(json.JSONEncoder): """json encoder""" -- GitLab