* Add backup timeout customization

* Different variable

* remote integrity check

* 3.4.2

* AND THEN

* words

* more words

* Add local backup integrity

* check local backup integrity

* Clarify duplicate backup verbage

* pulling

Co-authored-by: Michael Stanclift <vmstan@ms-constitution.local>
This commit is contained in:
Michael Stanclift 2021-04-06 13:38:19 -05:00 committed by GitHub
parent 71fdb016bd
commit d07e492a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 6 deletions

View File

@ -1 +1 @@
3.4.1
3.4.2

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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!"