Import sip.conf / extension.conf directly from old pbx

First time post here, hoping someone can offer me some help or advice.

I just created a new server running Elastix / FreePBX and I am attempting to get all the extensions into it from another already existing pbx. The existing pbx has no way of exporting this information in any usable form some I am stuck with the sip.conf and extensions.conf I found in the /etc/asterisk directory on the old pbx.

Is there anyway I can use either one of these or both of these files to create all the extensions I need on the new server?

I have been pulling my hair out searching for solution as there is easily over 500 extensions.


For that many extensions, it may be worth creating a script that compiles down the core information into a CSV file and trying to use the bulk import module to pull them in.

Of course by the time you have gone through all that you may be better off paying your teenage daughter/son (or a colleagues if you don’t have one) $10/hr to enter them…

In any event, you can still use the bulk extension module to go a bit quicker.

Ok, got a colleague thats a better scripter then I trying to tackle it. Otherwise I got quite a bit of data entry to do this weekend :confused:

Thanks for your reply, even though it’s not the one I had hoped for, I appreciate it!

We attempted to write a script that would parse the information from the old sip.conf file inject it into the php scripts used to create extensions, but obviously have something wrong as it does not seem to work.
Basically it was written to parse the data from each extension into an array and the push the array into the script. Here is the part of the script that attempts to inject the data:


    foreach ($arr_ext as $int_ext => $arr_data)
            $arrvars=split("&", $vars);
            foreach($arrvars as $var){
                    $arrvar=split("=", $var);

            core_devices_add($int_ext, "sip", "SIP/".$int_ext, "fixed", $int_ext, $arr_data['callerid'], "");

I think perhaps the wrong functions were chosen, but I am lost as to how to correct this.

Anyone have any suggestions on the correct way to inject this data?


forget trying to use the core_users_add and core_devices_add APIs, they are an ugly mess, trust me.

As I mentioned, just use the scripts to make a CSV file and use the bulkextensions module (in the extended repository) to import them. It’s already done the ugly work of figuring out the APIs.

Hi all

I’m trying using the bulkextensions module in Freepbx of an Elastix distro.

i can export the file, open wi Excel, add a new entry, with action=add export as csv again and then upload the file and got this message

Row 1: Headers parsed.
Row 2: Unrecognized action: the only actions recognized are add, edit, del.

what’s wrong? where is my error?


Make sure that you don’t have some hidden characters in the offending field.

Try entering a couple of extensions manually into the csv and see if that works.

Also make sure your csv file has the proper number of comma delimiters.

When you re-import the csv into excel does it look ok with the proper number of fields…even null fields?

I’ve been able to clean up csv files that might have hidden characters by reading them into notepad and then resaving them. Seems that notepad doesn’t save special characters.

I haven’t tried that specifically with FreePBx but it has worked in other csv applications.


I had the same problem just because I forgot to set separations between fiels:
that needs “,” and not “;” (and excel automatically sets “;”) ^^
Notepad++ and ctrl+F did the trick.
Have fun :wink:

Create change in file /admin/modules/bulkextensions/page.bulkextensions.php

while ($file_ok && (($aInfo = fgetcsv($fh, 2000, “,”, “”")) !== FALSE)) {

// $k++; // to comment

  if (empty($aInfo[0])) {
  // If this is the first row then we need to check each field listed (these are the headings)

//if ($i==0) { //bad var $i

if ($k==0){			
    for ($j=0; $j<count($aInfo); $j++) {
      $aKeys = array_keys($aFields);
      foreach ($aKeys as $sKey) {
    if ($aInfo[$j] == $sKey) {
          $aFields[$sKey][0] = true;
          $aFields[$sKey][1] = $j;

// $i++; // to comment
$k++; // changed