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 }