Is there a way to import trunks? I’m going to be making a bunch of trunk changes across a lot of PBXes and thinking of ways to make it go by faster.
I would look at how the trunks end up in the mysql DB, then make the SQL commands for the changes. Of course, is also possible for the astdb to be involved so need to look out for that but I believe that is mostly used for extension type things.
Looks like at least 2 tables in mysql for trunks: trunks and trunk_dialpatterns along with entries in the sip table for the sip configuration for a given trunk.
LoL, I always backup the database before doing this of course!
If you’re on a recent version of FreePBX, the Bulk Handler should be able to export and import trunk information. As always, I might have dreamed that, so verify before you do anything crazy.
Nah, trunks are not in bulk handler. That would be too easy.
Inbound routes are handled via the “DID” tab, but not trunks.
Trunks are scattered among the tables: trunks, trunk_dialpatterns, sip, and pjsip
It is not an easy thing to do
So I did some digging in the asterisk db… and trunks are stored in asterisk.trunks
but then the context of the sip channel settings for those trunks are placed in asterisk.pjsip or asterisk.sip and there are a BUNCH of rows that each trunk needs.
I’m going to still chase this a bit more… maybe making an extremely long SQL INSERT statement and script might do it.
It may not even work… because I still don’t know if just a “fwconsole reload” will tell FreePBX that I’ve updated the DB… then I still need to update the Outbound Routes, set priorities, etc.
At the least, I’ve learned something so far. This is the first time I’ve ever poked around the database and I learned you can easily use MySQL Workbench to SSH into FreePBX and then access the DB from there to browse around. I’m not a SQL beginner either… so learning the syntax too.
I looked at doing this for a migration from a raw asterisk system to a FreePBX 14 system. It simply is not worth the time.
No one (there is always an exception) should have so many trunks setup as to make this worth anyone’s time to script out compared to simply manually entering them.
Once entered on a modern system, you can backup the asterisk database itself and not worry about it.
In your case, you said
So you may be the exception that is worth it.
Define trunk changes better. It is likely you do not need a huge SQL statement just to change the couple bits that need changed.