Recursively deleting old backup files in backup directories
Be careful using this software - its deleting data (!)
python >= 3.6
- Clone pybackup repo to directory /usr/local on your backup host:
sudo git clone https://github.com/pavlovdo/pybackup /usr/local/pybackup
cd /usr/local/pybackup
A) Check execute permissions for scripts:
ls -l *.py *.sh
B) If not:
sudo chmod +x *.py *.sh
-
Change example configuration file pybackup.conf: backup main directory, default_storage_period. Also you can add or remove monitoring your backup directories in backup_custom_dirs.json for customize storage period or delete/not delete data in its. If you want to print all scanned directories then set Debug = True.
-
Further you have options: run scripts from host or run scripts from docker container.
If you want to run scripts from host:
C) Plan deleting old backups and create cron jobs:
echo "00 04 * * * /usr/local/pybackup/pybackup.py > /usr/local/pybackup/data/output" > /tmp/crontab && \
crontab /tmp/crontab && rm /tmp/crontab
If you want to run scripts from docker container:
A) Run build.sh:
cd /usr/local/pybackup
./build.sh
B) Run dockerrun.sh;
./dockerrun.sh
Cent OS 7.8, 8.2