diff options
-rw-r--r-- | src/xbackup/prune.py | 21 |
1 files changed, 20 insertions, 1 deletions
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 + "'") |