Can we have an option to keep old queries when we do "restartdns"?


Sometimes I need to run
pihole restartdns
to fix some pihole issues, currently this command clears "Total queries over last 24 hours" and causes empty history in Dashboard page (i.e., no data for "Totoal Queries" "Queries Blocked", "Percent Blocked", and "Total queries over last 24 hours" graph).

I am not sure why a simple "restarting server" needs to clear its log/history, but please give us an option to keep and reload the history so after "restartdns" we still have last 24 hours' queries.

By the way, I don't have /etc/pihole/pihole-FTL.db because I have


in my /etc/pihole/pihole-FTL.conf.


You don't wan't to keep history but want to be store the last 24h when running pihole restartdns? That doesn't go together.

You have to decide: keep history or don't keep it.

What you might want, is ``MAXDBDAYS=1`

hmm... OK, then where does pihole save the 24-hour queries after it has ran for 24 hours? Obviously it does not depend on MAXDBDAYS because it has working stat during its run.


MAXDBDAYS is the parameter that controls the duration of query storage in this file.

A separate configuration parameter (MAXLOGAG) determines how many hours of data are read from his file on restart: Default and maximum are 24 hours. When there is no database, there is nothing to read. This is why MAXDBDAYS = 1 will provide enough history to populate the dashboard.

Thanks for the reply, but my question was: during its run, how is pihole able to accumulate and display these query data when it does not save or have /etc/pihole/pihole-FTL.db at all? these data must be somewhere, maybe in the memory?

They are kept in memory, as well as being written to the database if available. When you restartdns, this clears the memory and the information is lost. Normally this would be populated from the long term database on FTL startup, but if the long term database is disabled, you have nothing.

You have disabled the existing option to restore the previous 24 hour query history.

What problems are you having that cause you to restartdns frequently? Most Pi-hole will run forever without ever doing this.

Thanks for the clarification.

Yeah, pihole used to work for months without problems, but since pihole 5, mine stops answering requests on every Sunday morning, as described in this topic:
I still have this problem after I updated to the latest version (Pi-hole v5.1.2 Web Interface v5.1.1 FTL v5.2.), and last week I decided to comment out the "pihole updateGravity" line from /etc/cron.d/pihole.

Implemented by

and released with Pi-hole FTL v5.14, Web v5.11 and Core v5.9 released