diff --git a/VERSION b/VERSION index 8cf6caf..a423d42 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.4.1 \ No newline at end of file +3.4.2 \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index b4d5d38..ffe6c7b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -3,8 +3,7 @@ SCRIPT_START=$SECONDS # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='3.4.1' - +VERSION='3.4.2' # For documentation or downloading updates visit https://github.com/vmstan/gravity-sync # Requires Pi-Hole 5.x or higher already be installed, for help visit https://pi-hole.net diff --git a/includes/gs-backup.sh b/includes/gs-backup.sh index 6b970f3..fd3a103 100644 --- a/includes/gs-backup.sh +++ b/includes/gs-backup.sh @@ -12,6 +12,7 @@ function task_backup() { backup_settime backup_local_gravity + backup_local_gravity_integrity backup_local_custom backup_local_cname backup_cleanup @@ -32,6 +33,22 @@ function backup_local_gravity() { error_validate } +function backup_local_gravity_integrity() { + MESSAGE="${UI_BACKUP_INTEGRITY}" + echo_stat + + secondaryIntegrity=$(sqlite3 ${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${GRAVITY_FI}.backup 'PRAGMA integrity_check;' | sed 's/\s.*$//') + error_validate + + if [ "$secondaryIntegrity" != 'ok' ] + then + MESSAGE="${UI_BACKUP_INTEGRITY_FAILED} ${UI_GRAVITY_NAME}" + echo_fail + + exit_nochange + fi +} + function backup_local_custom() { if [ "$SKIP_CUSTOM" != '1' ] then @@ -75,6 +92,22 @@ function backup_remote_gravity() { create_sshcmd } +function backup_remote_gravity_integrity() { + MESSAGE="${UI_BACKUP_INTEGRITY}" + echo_stat + + primaryIntegrity=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sqlite3 ${RIHOLE_DIR}/${GRAVITY_FI}.backup 'PRAGMA integrity_check;'" | sed 's/\s.*$//') + error_validate + + if [ "$primaryIntegrity" != 'ok' ] + then + MESSAGE="${UI_BACKUP_INTEGRITY_FAILED} ${UI_GRAVITY_NAME}" + echo_fail + + exit_nochange + fi +} + function backup_remote_custom() { if [ "$SKIP_CUSTOM" != '1' ] then diff --git a/includes/gs-pull.sh b/includes/gs-pull.sh index e1b26d9..d75f52c 100644 --- a/includes/gs-pull.sh +++ b/includes/gs-pull.sh @@ -31,6 +31,7 @@ function pull_gs_grav { backup_local_gravity backup_remote_gravity + backup_remote_gravity_integrity MESSAGE="${UI_PULL_PRIMARY} ${UI_GRAVITY_NAME}" echo_stat diff --git a/includes/gs-push.sh b/includes/gs-push.sh index 2ff4762..dae1f5b 100644 --- a/includes/gs-push.sh +++ b/includes/gs-push.sh @@ -30,8 +30,9 @@ function task_push { function push_gs_grav { backup_remote_gravity backup_local_gravity + backup_local_gravity_integrity - MESSAGE="${UI_BACKUP_PRIMARY} ${UI_GRAVITY_NAME}" + MESSAGE="${UI_BACKUP_COPY} ${UI_GRAVITY_NAME}" echo_stat RSYNC_REPATH="rsync" RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/${GRAVITY_FI}.backup" @@ -67,7 +68,7 @@ function push_gs_cust { backup_remote_custom backup_local_custom - MESSAGE="${UI_BACKUP_PRIMARY} ${UI_CUSTOM_NAME}" + MESSAGE="${UI_BACKUP_COPY} ${UI_CUSTOM_NAME}" echo_stat RSYNC_REPATH="rsync" RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/${CUSTOM_DNS}.backup" @@ -105,7 +106,7 @@ function push_gs_cname { backup_remote_cname backup_local_cname - MESSAGE="${UI_BACKUP_PRIMARY} ${UI_CNAME_NAME}" + MESSAGE="${UI_BACKUP_COPY} ${UI_CNAME_NAME}" echo_stat RSYNC_REPATH="rsync" RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/dnsmasq.d-${CNAME_CONF}.backup" diff --git a/includes/gs-ui.sh b/includes/gs-ui.sh index 6996618..504eaca 100644 --- a/includes/gs-ui.sh +++ b/includes/gs-ui.sh @@ -77,9 +77,12 @@ UI_LOGGING_RECENT_COMPLETE='Recent complete executions of' # Backup UI_BACKUP_PRIMARY='Performing backup of primary' +UI_BACKUP_COPY='Pulling backup of primary' UI_BACKUP_SECONDARY='Performing backup of secondary' UI_BACKUP_PURGE='Purging redundant backups on secondary Pi-hole instance' UI_BACKUP_REMAIN='days of backups remain' +UI_BACKUP_INTEGRITY="Checking ${UI_GRAVITY_NAME} backup integrity" +UI_BACKUP_INTEGRITY_FAILED='Integrity check has failed for the primary' # Restore UI_RESTORE_WARNING="This will overwrite your current Pi-hole settings on $HOSTNAME with a previous version!"