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