Exporting DID numbers to CSV

Status
Not open for further replies.

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,038
556
113
There was a question today on IRC:
Anyone know if it's possible to export a complete list of DIDs from FusionPBX system wide? Trying to do a mass number porting and this would make my life alot easier


Here's a quick and dirty answer:

Code:
sudo -u postgres psql -d fusionpbx -c "\copy (select destination_number from v_destinations) to '/tmp/didnumbers.csv' with csv";


To export just a particular domains did numbers:

Code:
sudo -u postgres psql -d fusionpbx -c "\copy (select destination_number from v_destinations INNER JOIN v_domains on v_destinations.domain_uuid=v_domains.domain_uuid where v_domains.domain_name = 'mydomain.pbx.com') to '/tmp/didnumbers.csv' with csv";


Results will be in /tmp/didnumbers.csv. Obviously, change mydomain.pbx.com to suit.
 
Status
Not open for further replies.