diff --git a/ADVANCED.md b/ADVANCED.md index 4ce0455..b9201c9 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -169,6 +169,11 @@ 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. + +Default setting in Gravity Sync is 7, adjust as resired. + ## Execution If you are just straight up unable to run the `gravity-sync.sh` file, make sure it's marked as an executable by Linux. diff --git a/gravity-sync.conf.example b/gravity-sync.conf.example index c125d38..1e55653 100644 --- a/gravity-sync.conf.example +++ b/gravity-sync.conf.example @@ -33,3 +33,5 @@ REMOTE_PASS='' # SKIP_CUSTOM='' # DATE_OUTPUT='' # PING_AVOID='' + +# BACKUP_RETAIN='' \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index d2629bb..3980f7b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -32,6 +32,9 @@ SKIP_CUSTOM='0' # replace in gravity-sync.conf to overwrite DATE_OUTPUT='0' # replace in gravity-sync.conf to overwrite PING_AVOID='0' # replace in gravity-sync.conf to overwrite +# Backup Customization +BACKUP_RETAIN='7' # replace in gravity-sync.conf to overwrite + # Pi-hole Folder/File Locations PIHOLE_DIR='/etc/pihole' # default Pi-hole data directory GRAVITY_FI='gravity.db' # default Pi-hole database file @@ -1611,16 +1614,18 @@ function task_backup { MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="Performing SQLITE3 Backup of ${GRAVITY_FI}" + BACKUPTIMESTAMP=$(date +%F-%H%M%S) + + MESSAGE="Performing Backup of ${GRAVITY_FI}" echo_stat - sqlite3 ${PIHOLE_DIR}/${GRAVITY_FI} ".backup '$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/$(date +%F-%H%M%S)-${GRAVITY_FI}.backup'" + sqlite3 ${PIHOLE_DIR}/${GRAVITY_FI} ".backup '$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${GRAVITY_FI}.backup'" error_validate - MESSAGE="Backing Up ${CUSTOM_DNS}" + MESSAGE="Performing Backup Up ${CUSTOM_DNS}" echo_stat - cp ${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/$(date +%F-%H%M%S)-${GRAVITY_FI}.backup + cp ${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${CUSTOM_DNS}.backup error_validate exit_withchange