diff options
author | xengineering <me@xengineering.eu> | 2021-10-09 12:12:30 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2021-10-09 12:12:30 +0200 |
commit | f28fe2c372eefd64bbe3e6b2837b0734e002c3cc (patch) | |
tree | bf0c38c94523e34d109025f3daf106f0dd1fb0a4 | |
parent | 4d984ac7be037031fe27137dd5b09cf978e6ac00 (diff) | |
download | xbackup-f28fe2c372eefd64bbe3e6b2837b0734e002c3cc.tar xbackup-f28fe2c372eefd64bbe3e6b2837b0734e002c3cc.tar.zst xbackup-f28fe2c372eefd64bbe3e6b2837b0734e002c3cc.zip |
Implement Generation of prune Command
-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 + "'") |