diff --git a/README.md b/README.md index ee52806dd5f2f33f04efcfe9794c777cc0d2cd4d..d3d1c57da782894d5c36be22b9d9a88049ecbd10 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 0cd68ce729ab3aa17badc2c66362a1336ea8083d..84a4de5fb08ed0fdc5e45d5f5262d92411f24006 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"""