From 4946b5907bf4d45fda807558e2e0234ed70db784 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 28 Apr 2019 22:15:47 +0200 Subject: [PATCH] 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 --- gravity.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index a3456fb4..6e238e68 100755 --- a/gravity.sh +++ b/gravity.sh @@ -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