pi-hole:block_lists:extract_blocklist_domains_to_a_file
Table of Contents
Pi-Hole - Block Lists - Extract Blocklist Domains to a File
sqlite3 /etc/pihole/gravity.db "SELECT DISTINCT domain FROM gravity;" > OUT.txt
If you want to link those out to the adlists they came from:
sqlite3 /etc/pihole/gravity.db "SELECT gravity.domain, adlist.address FROM gravity JOIN adlist ON adlist.id = gravity.adlist_id;" > OUT.txt
Export domains
sudo sqlite3 /etc/pihole/gravity.db "SELECT domain FROM gravity WHERE rowid IN (SELECT rowid FROM gravity GROUP BY domain);" > /etc/pihole/custom/gravity.txt
Export blacklist
sudo sqlite3 /etc/pihole/gravity.db "SELECT domain FROM domainlist WHERE enabled = 1 AND type = 1;" >> /etc/pihole/custom/gravity.txt
Export Whitelist
sudo sqlite3 /etc/pihole/gravity.db "SELECT DISTINCT domain FROM domainlist WHERE type=0;" >> /etc/pihole/custom/whitelist.txt
Remove whitelist from exported domains
grep -Fvx -f /etc/pihole/custom/whitelist.txt /etc/pihole/custom/gravity.txt | sponge /etc/pihole/custom/gravity.txt #Sort and dedupe sort /etc/pihole/custom/gravity.txt | uniq | sponge /etc/pihole/custom/gravity.txt
pi-hole/block_lists/extract_blocklist_domains_to_a_file.txt · Last modified: 2021/01/20 20:58 by peter