diff --git a/states/kopia/templates/kopia_backup.py.j2 b/states/kopia/templates/kopia_backup.py.j2 index bf2dd22..2120dd9 100644 --- a/states/kopia/templates/kopia_backup.py.j2 +++ b/states/kopia/templates/kopia_backup.py.j2 @@ -50,10 +50,10 @@ def set_policy(compression="zstd"): return run_policy.returncode == 0 -def set_cache(): +def set_cache(size=500, limit=1000): rcs = [] - cmds_cache = [f"{KOPIA_EXEC} cache set --content-cache-size-mb 1000 --config-file={KOPIA_CONFIG_PATH}", - f"{KOPIA_EXEC} cache set --content-cache-size-limit-mb 2000 --config-file={KOPIA_CONFIG_PATH}"] + cmds_cache = [f"{KOPIA_EXEC} cache set --content-cache-size-mb {size} --config-file={KOPIA_CONFIG_PATH}", + f"{KOPIA_EXEC} cache set --content-cache-size-limit-mb {limit} --config-file={KOPIA_CONFIG_PATH}"] for cmd_cache in cmds_cache: run_cache = Popen(cmd_cache, shell=True, stdout=PIPE, stderr=PIPE) run_cache.wait() @@ -98,7 +98,7 @@ if __name__ == "__main__": if not set_policy(): print("set policy error") sys.exit(1) - if not set_cache(): + if not set_cache({{ kopia.repos[params.repo].cache_size|default(500) }},{{ kopia.repos[params.repo].cache_limit|default(1000) }}): print("set cache error") sys.exit(1) if not run(before_tasks={{ params.before_tasks|default([]) }}):