Bulk upload of Blacklist Numbers

Discussion in 'General' started by pucky900, Nov 5, 2010.

  1. pucky900

    Joined:
    Feb 9, 2009
    Messages:
    51
    Likes Received:
    0
    I'm currently trying to migrate from Trixbox CE to Elastix and trying to find an easy to move my blacklist of numbers to a new system without having to enter each one. I've dug into the Asterisk DB but never have found it's location. Help would be greatly appreciated.
     
  2. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    They are maintained in the Asterisk berkeley database

    you can get the old ones from the old machine with

    rasterisk -x 'database show blacklist'

    you can add them to the new one with

    rasterisk -x 'database put blacklist <number> 1'

    you can delete them with

    rasterisk -x 'database del blacklist <NUMBER>'

    write a shell script to do it quicker :)

    perhaps something like this ugly but I hope functional (I never tried it ;) ) one liner run from the old machine:
    Code:
    rasterisk -x 'database show blacklist'|sed 's/^/rasterisk -x "database put /'|sed -s 's|/| |g'|sed 's/\s*://'|sed 's/$/"/' > xxx;ssh <new_machine_ip_or_name> sh  < xxx;rm -f xxx;ssh <new_machine_ip_or_name>  "rasterisk -x 'database show blacklist'"
    
    ref:
    man sed
    man sh
    man ssh
    http://www.voip-info.org

    dicko
     
  3. pucky900

    Joined:
    Feb 9, 2009
    Messages:
    51
    Likes Received:
    0
    I actually found a super super easier way. All I need to do was to go into /var/lib/asterisk and copy the 'astdb' file from the old machine to my new one. Restarted my new machine and there they were.

    Found it under the "Backup/Restore" section
    http://www.voip-info.org/wiki/view/Asterisk+database
     

Share This Page