AI agents & screen readers: for a machine-readable, text-only catalogue, start at /llms.txt. Products are available as Markdown (/products.md, /products/{handle}.md) and JSON (/products.json, /products/{handle}.json).
Store

Database maintenance

Maintenance and Monitoring

Pi-hole uses an SQLite database (gravity.db) to store DNS query logs, blocklists, and other essential data. Regular maintenance helps ensure optimal performance and efficient disk space usage. Here are the key maintenance tasks:

Basic Maintenance

1. Flush Query Logs

To clear long-term query logs when they consume too much space:

pihole -f

2. Update Blocklists

To refresh your protection by updating blocklists:

pihole -g

3. Rebuild Gravity Database

If you notice slow queries or errors, rebuild the database:

pihole -g -r

4. Backup Settings

Create a backup of your Pi-hole configuration:

pihole -a -t

Advanced Maintenance

5. Manual Database Reset

If the database becomes corrupted, you can clear it with these commands:

sudo service pihole-FTL stop
sudo rm /etc/pihole/pihole-FTL.db
sudo service pihole-FTL start

6. Database Optimization

Reclaim unused space in the database:

sqlite3 /etc/pihole/pihole-FTL.db "VACUUM;"

7. Database Health Check

Verify database integrity if you suspect corruption:

sqlite3 /etc/pihole/pihole-FTL.db "PRAGMA integrity_check;"

Regular maintenance will help keep your Pi-hole installation running efficiently and prevent performance issues. Consider scheduling these tasks at regular intervals based on your usage patterns.

Something here not working for you? Ask in the community — other makers and the Little Bird team read it.

Search The Pi-Hole Book

Type a word or phrase to search all 74 pages.

Ask The Pi-Hole Book

Answers come from this book only.

Talk to The Pi-Hole Book

Ask it out loud and it answers in your ear, from this book's own pages — the right command, the right setting, and the page it came from.

Unlock the tutor

Already bought it, or had an account on books.littlebird.com.au? Sign in.

Maddy, co-founder of Little Bird

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.