separate rentention code
This commit is contained in:
parent
d0a3b2f5fa
commit
abe881ff40
@ -13,6 +13,7 @@ def cmd_backup(args, parser):
|
||||
|
||||
try:
|
||||
run_backup(args.name, config)
|
||||
run_retention(args.name, config)
|
||||
# update statefile if configured
|
||||
if config.statefile:
|
||||
path = config.statefile.format(name=args.name)
|
||||
@ -25,16 +26,11 @@ def cmd_backup(args, parser):
|
||||
|
||||
|
||||
def run_backup(name, config):
|
||||
# the tags in both backup_tags and retention_tags will be added to the backup
|
||||
backup_tags = {}
|
||||
# the tags in retention_tags will be used when pruning backups
|
||||
retention_tags = {
|
||||
# these tags will be added to the backup. They need to match retention_tags in run_rentention, below
|
||||
backup_tags = {
|
||||
"name": name,
|
||||
}
|
||||
|
||||
all_tags = dict(retention_tags)
|
||||
all_tags.update(backup_tags)
|
||||
|
||||
# perform pre/post-exec
|
||||
# post-exec is executed if the backup fails OR if any pre-exec commands fail
|
||||
# pre-exec commands failing will stop the backup from being executed
|
||||
@ -49,7 +45,7 @@ def run_backup(name, config):
|
||||
|
||||
# run backup
|
||||
backup_cmd = ["backup", "./"]
|
||||
for k, v in all_tags.items():
|
||||
for k, v in backup_tags.items():
|
||||
backup_cmd.extend(["--tag", "{}={}".format(k, v)])
|
||||
for entry in config.backup.exclude:
|
||||
if entry.startswith("/"):
|
||||
@ -58,6 +54,13 @@ def run_backup(name, config):
|
||||
|
||||
checkp(config.run(backup_cmd))
|
||||
|
||||
|
||||
def run_retention(name, config):
|
||||
# the tags in retention_tags will be used when pruning backups
|
||||
retention_tags = {
|
||||
"name": name,
|
||||
}
|
||||
|
||||
# perform retention
|
||||
retention_args = get_retention_args(config.backup.schedule)
|
||||
if retention_args:
|
||||
|
Loading…
x
Reference in New Issue
Block a user