From 693ca75715d084f97ca0a825f7d9524f89e72ae1 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Fri, 10 Jul 2020 22:19:28 -0500 Subject: [PATCH] Backup cleanup --- ADVANCED.md | 2 +- gravity-sync.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ADVANCED.md b/ADVANCED.md index b9201c9..318f5a6 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -170,7 +170,7 @@ The `./gravity-sync.sh config` function will attempt to ping the remote host to Default setting in Gravity Sync is 0, change to 1 to skip this network test. #### `BACKUP_RETAIN=''` -The `./gravity-sync.sh backup` function will retain a defined number of previous `gravity.db` and `custom.list` backups. +The `./gravity-sync.sh backup` function will retain a defined number of days worth of `gravity.db` and `custom.list` backups. Default setting in Gravity Sync is 7, adjust as resired. diff --git a/gravity-sync.sh b/gravity-sync.sh index 3980f7b..ebfa19b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1627,6 +1627,12 @@ function task_backup { cp ${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${CUSTOM_DNS}.backup error_validate + + MESSAGE="Cleaning Up Old Backups" + echo_stat + + find $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/$(date +%Y)*.backup -mtime +${BACKUP_RETAIN} -type f -delete + error_validate exit_withchange }