Move migrated files to backup directory instead of deleting them. This has the benefit that gravity.db can be recreated at any time by: 1. deleting gravity.db, 2. copying all files from the migration_backup directory back to /etc/pihole, 3. running pihole -g again.

Signed-off-by: DL6ER <dl6er@dl6er.de>
pull/2611/head
DL6ER 5 years ago
parent efeba594ae
commit 4946b5907b
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

@ -89,6 +89,8 @@ database_table_from_file() {
# Define locals
local table="${1}"
local source="${2}"
local backup_path="${piholeDir}/migration_backup"
local backup_file="${backup_path}/$(basename "${2}")"
# Create database file if not present
if [ ! -e "${gravityDBfile}" ]; then
@ -140,8 +142,9 @@ database_table_from_file() {
rm "${tmpFile}" > /dev/null 2>&1 || \
echo -e " ${CROSS} Unable to remove ${tmpFile}"
# Delete source file
rm "${source}" 2> /dev/null || \
# Move source file to backup directory, create directory if not existing
mkdir -p "${backup_path}"
mv "${source}" "${backup_file}" 2> /dev/null || \
echo -e " ${CROSS} Unable to remove ${source}"
}
@ -702,7 +705,6 @@ fi
# Gravity downloads blocklists next
gravity_CheckDNSResolutionAvailable
gravity_GetBlocklistUrls
if gravity_GetBlocklistUrls; then
gravity_SetDownloadOptions
# Build preEventHorizon

Loading…
Cancel
Save