From f28fe2c372eefd64bbe3e6b2837b0734e002c3cc Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 9 Oct 2021 12:12:30 +0200 Subject: Implement Generation of prune Command --- src/xbackup/prune.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/xbackup/prune.py b/src/xbackup/prune.py index 723161a..77085d0 100644 --- a/src/xbackup/prune.py +++ b/src/xbackup/prune.py @@ -8,7 +8,26 @@ This module contains the pruning functionality of xbackup. """ +import os + + def prune(backup_cfg, prune_cfg, scripted): """prune backups""" - pass + # generate backup repository path + hostname = os.uname()[1] + repo = os.path.join(backup_cfg["borg_repos_folder"], hostname) + + # parse prune values + hourly = prune_cfg["keep-hourly"] + daily = prune_cfg["keep-daily"] + weekly = prune_cfg["keep-weekly"] + monthly = prune_cfg["keep-monthly"] + yearly = prune_cfg["keep-yearly"] + + # generate command + cmd = f"borg prune -v {repo}" + cmd += f" -H {hourly} -d {daily} -w {weekly} -m {monthly} -y {yearly}" + + # print command for debugging + print("\nCould execute prune command like this:\n'" + cmd + "'") -- cgit v1.2.3-70-g09d2