mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-22 07:10:19 +00:00
Put gravity backup files into dedicated directory for cleaness
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
fab1ca3a40
commit
12927f8a3d
1 changed files with 14 additions and 6 deletions
10
gravity.sh
10
gravity.sh
|
@ -58,7 +58,8 @@ gravityDBfile_default="/etc/pihole/gravity.db"
|
||||||
gravityTEMPfile="${GRAVITYDB}_temp"
|
gravityTEMPfile="${GRAVITYDB}_temp"
|
||||||
gravityDIR="$(dirname -- "${gravityDBfile}")"
|
gravityDIR="$(dirname -- "${gravityDBfile}")"
|
||||||
gravityOLDfile="${gravityDIR}/gravity_old.db"
|
gravityOLDfile="${gravityDIR}/gravity_old.db"
|
||||||
gravityBCKfile="${gravityDIR}/gravity_backup.db"
|
gravityBCKdir="${gravityDIR}/gravity_backups"
|
||||||
|
gravityBCKfile="${gravityBCKdir}/gravity.db"
|
||||||
|
|
||||||
fix_owner_permissions() {
|
fix_owner_permissions() {
|
||||||
# Fix ownership and permissions for the specified file
|
# Fix ownership and permissions for the specified file
|
||||||
|
@ -132,6 +133,11 @@ gravity_swap_databases() {
|
||||||
if [[ "${status}" -ne 0 ]]; then
|
if [[ "${status}" -ne 0 ]]; then
|
||||||
echo -e "\\n ${CROSS} Unable to clean current database for backup\\n ${output}"
|
echo -e "\\n ${CROSS} Unable to clean current database for backup\\n ${output}"
|
||||||
else
|
else
|
||||||
|
# Check if the backup directory exists
|
||||||
|
if [ ! -d "${gravityBCKdir}" ]; then
|
||||||
|
mkdir -p "${gravityBCKdir}"
|
||||||
|
fi
|
||||||
|
|
||||||
# If multiple gravityBCKfile's are present (appended with a number), rotate them
|
# If multiple gravityBCKfile's are present (appended with a number), rotate them
|
||||||
# We keep at most 10 backups
|
# We keep at most 10 backups
|
||||||
rotate_gravity_backup
|
rotate_gravity_backup
|
||||||
|
@ -434,11 +440,13 @@ gravity_DownloadBlocklists() {
|
||||||
echo -e "\\n ${CROSS} Unable to copy data from ${gravityDBfile} to ${gravityTEMPfile}\\n ${output}"
|
echo -e "\\n ${CROSS} Unable to copy data from ${gravityDBfile} to ${gravityTEMPfile}\\n ${output}"
|
||||||
|
|
||||||
# Try to attempt a backup restore
|
# Try to attempt a backup restore
|
||||||
|
if [[ -d "${gravityBCKdir}" ]]; then
|
||||||
for i in {1..10}; do
|
for i in {1..10}; do
|
||||||
if try_restore_backup "${i}"; then
|
if try_restore_backup "${i}"; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# If none of the attempts worked, return 1
|
# If none of the attempts worked, return 1
|
||||||
if [[ "${i}" -eq 10 ]]; then
|
if [[ "${i}" -eq 10 ]]; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue