Skip to content
Snippets Groups Projects
Commit 2acfbf24 authored by Radoslav Bodó's avatar Radoslav Bodó
Browse files

rwm: add tags to backup config

parent 683f01f7
No related branches found
No related tags found
No related merge requests found
Pipeline #7738 passed
......@@ -18,25 +18,21 @@ backups:
- "/var/lib/mysql/*"
- "/var/lib/postgresql/*"
- "/var/run/*"
extras: ["--one-file-system", "--tag", "simplefs"]
tags:
- "simplefs"
extras:
- "--one-file-system"
mysql:
filesdirs:
- /var/lib/rwm/mysql.tar.gz
extras: ["--tag", "mysql"]
tags:
- "mysql"
prerun:
- "/opt/rwm/scripts/backup_mysql.py create"
postrun:
- "/opt/rwm/scripts/backup_mysql.py cleanup"
nas:
filesdirs:
- /mnt/nas
prerun:
- mount
postrun:
- unmount
retention:
keep-daily: "60"
keep-within: "60d"
......
......@@ -79,6 +79,9 @@ class BackupConfig(BaseModel):
excludes:
List of patterns for `--exclude` options for `restic backup` commmand. Defaults to an empty list.
tags:
List of tags for the new backup snapshot. Defaults to an empty list.
extras:
Additional options for the `restic backup` commmand. Defaults to an empty list.
......@@ -93,6 +96,7 @@ class BackupConfig(BaseModel):
filesdirs: List[str]
excludes: List[str] = []
tags: List[str] = []
extras: List[str] = []
prerun: List[str] = []
postrun: List[str] = []
......@@ -552,10 +556,16 @@ class RWM:
logger.info(f"_restic_backup {name}")
conf = self.config.backups[name]
excludes = []
for item in conf.excludes:
excludes += ["--exclude", item]
cmd_args = ["backup"] + conf.extras + excludes + conf.filesdirs
tags = []
for item in conf.tags:
tags += ["--tag", item]
cmd_args = ["backup"] + conf.extras + tags + excludes + conf.filesdirs
wrap_output(backup_proc := self.restic_cmd(cmd_args))
return backup_proc.returncode
......
......@@ -128,7 +128,8 @@ def test_backup(tmpworkdir: str, motoserver: str): # pylint: disable=unused-arg
"testcfg": {
"filesdirs": ["testdatadir/"],
"excludes": ["testfile_to_be_ignored"],
"extras": ["--tag", "dummytag"],
"tags": ["dummytag"],
"extras": ["--one-file-system"],
}
},
"retention": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment