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>
This commit is contained in:
DL6ER 2019-04-28 22:15:47 +02:00
parent efeba594ae
commit 4946b5907b
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

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