# How to add multiple (bulk) blocklists via CLI in 5.0?

**URL:** https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064
**Category:** Customizing Pi-hole
**Tags:** v5-0
**Created:** [May 21, 2020, 8:02pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064 "2020-05-21T20:02:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![techstuff](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@techstuff](https://discourse.pi-hole.net/u/techstuff)
#### Post date: [May 21, 2020, 8:02pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/1 "2020-05-21T20:02:59Z")

</div>

Previously (before 5.0) you could bulk add blocklists by:  
**curl [https://example.com](https://example.com) | sudo tee adlists.list**

What's the proper way to do it via CLI now ? I found a few threads but since it's a database thing I don't want to screw it up.

> [Scripting Adlist Management in v5 - #3 by papasan](https://discourse.pi-hole.net/t/scripting-adlist-management-in-v5/31962/3)  
> [Blocklist Management in PiHole v5 - #7 by jpgpi250](https://discourse.pi-hole.net/t/blocklist-management-in-pihole-v5/31971/7)

Someone in this thread says the following works:

```auto
sudo sqlite3 /etc/pihole/gravity.db "DELETE FROM adlist"
sudo wget -qO - https://v.firebog.net/hosts/lists.php?type=tick |xargs -I {} sudo sqlite3 /etc/pihole/gravity.db "INSERT INTO adlist (Address) VALUES ('{}');"
pihole -g

```

Does that look clean/safe ? I see alot of people asking how to do this so maybe you guys could add it to the GUIDE/FAQ to help others

Thanks

---

<div class="post-metadata">

### Author: ![papasan](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@papasan](https://discourse.pi-hole.net/u/papasan)
#### Post date: [May 21, 2020, 8:34pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/2 "2020-05-21T20:34:30Z")

</div>

that's my code, hacked together for the same purpose. although the above works I think the _best_ way would be to grab the new list, compare it to what's in the database, and add/remove as needed. above would fail badly if firebog.net is not available for any reason.

p.s. the first 'sudo' on the second line isn't needed.

---

<div class="post-metadata">

### Author: ![jpgpi250](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jpgpi250/32/286_2.png) [@jpgpi250](https://discourse.pi-hole.net/u/jpgpi250)
#### Post date: [May 21, 2020, 9:29pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/3 "2020-05-21T21:29:55Z")

</div>

DELETE FROM adlist will remove all entries.  
the insert command may or may not work (I didn't test it), however you'll end up with only the entries from the firebog list.

If you want to keep existing entries, and add possible new entries form the firebog list:

- don't execute the delete command
- change the INSERT command into INSERT OR IGNORE, this will prevent errors, when trying to add lists that are already in the database.

Again, I've never tested this command, it may or may not work

The example uses the [ticked](https://v.firebog.net/hosts/lists.php?type=tick) firebog list, I've been using the [nocross](https://v.firebog.net/hosts/lists.php?type=nocross) firebog list. That's a choice you need to make, read [here](https://v.firebog.net/hosts/lists.php).  
I have been using this [script](https://github.com/jpgpi250/piholemanual/blob/aed89e6768c486d6804cd4906d6b4bb1dfc96cc1/firebog.sh) successfully. **Don't forget to make the required changes (ticked or nocross)**. Of course, you'll need to run `pihole -g` after running the script.

---

<div class="post-metadata">

### Author: ![mmotti](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/mmotti/32/9927_2.png) [@mmotti](https://discourse.pi-hole.net/u/mmotti)
#### Post date: [May 21, 2020, 10:05pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/4 "2020-05-21T22:05:24Z")

</div>

You could use a script that I've written to export as flat files, make changes and import again.

It just depends how adventurous you are.

> **[GitHub - mmotti/PyPhDB: Extract your adlists, whitelists, blacklists and...](https://github.com/mmotti/PyPhDB)**
>
> Extract your adlists, whitelists, blacklists and regexps, edit and re-upload to Pi-hole

---

<div class="post-metadata">

### Author: ![techstuff](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@techstuff](https://discourse.pi-hole.net/u/techstuff)
#### Post date: [May 22, 2020, 12:21am UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/5 "2020-05-22T00:21:01Z")

</div>

Thanks for all the ideas/input. I've settled on the @jpgpi250 script since I prefer bash. Seems to work great, I only changed the paths for "sed" (not sure if you intended /tmp to be there) and added 'pihole -g' at the end as recommended.

---

<div class="post-metadata">

### Author: ![papasan](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@papasan](https://discourse.pi-hole.net/u/papasan)
#### Post date: [May 23, 2020, 6:38pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/6 "2020-05-23T18:38:19Z")

</div>

a better solution than my ham-fisted attempt, but your script is lacking in that it won't pull out any lists that drop out of the firebog repo (your script only adds, never removes).

---

<div class="post-metadata">

### Author: ![system](https://discourse.pi-hole.net/uploads/default/original/3X/7/c/7c8792f649eeb921c5d2b4c41564ffa873d9a2b8.png) [@system](https://discourse.pi-hole.net/u/system)
#### Post date: [June 13, 2020, 6:43pm UTC](https://discourse.pi-hole.net/t/how-to-add-multiple-bulk-blocklists-via-cli-in-5-0/33064/7 "2020-06-13T18:43:28Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
