• Vik Jaswal

Backup Sonus SBC (UX) 1000/2000 using PowerShell & REST API’s

As discussed in previous article the REST API license is provided free of charge to all Sonus SBC (UX) 1000/2000 customers with a valid support contract when upgrading to Release 3.0.This has opened whole lot of possibilities to manage Sonus devices programmatically which wasn’t available until now.

One area which has been very tedious was backing up Sonus devices on regular basis. As with other Lync components you do want some automated way to backup the Sonus configuration as well e.g.: once a day. Until now the backups (until you already had REST API license) were manual but with REST API’s licenses all that changes. Now you can quite easily include the backup of the Sonus SBC’s as part of the overall Lync infrastructure.

We will use cURL to backup Sonus SBC’s. Make sure you have gone through my previous article which shows how to setup and login to UX using cURL. To backup the Sonus device all you have to do is issue the following command:

.\curl.exe -s -k -i https://HOSTNAME/rest/system?action=backup –data “” –cookie COOKIE -o BACKUPFOLDER\BACKUPFILE –insecure’

Make sure you replace values in RED appropriately.

Well, using cURL is all well and good, but then you still only have semi-automatic way to backup and still need some work to automate this completely.

Backup Sonus SBC using PowerShell

To fully automate the backups of Sonus SBC’s I have created a PowerShell script. All this script does is run cURL but you have got additional settings which can help you manage the backups e.g.:

  1. Backup multiple SBC’s at the same time

  2. Specify number of versions to keep

  3. Schedule backup using Task scheduler

  4. Organise SBC backups

  5. Integrate the script with Lync backup script

Script Pre-requisites

For the script to run successfully the following pre-requisites should be met.

  1. Ensure you have upgraded Sonus SBC to R3.0

  2. Ensure you have applied the base version 3.0 license which contains the license for REST which is what is used for backing up the SBC

  3. Ensure you have created a username and password for REST. For more details check out: http://www.allthingsuc.co.uk/accessing-sonus-ux-with-rest-apis/

Script Execution

Once you have met the script pre-requisites you are good to run the script:

Download the zip file from here and extract to your local machine. The file contains 3 files – a PowerShell script, template CSV file and cURL.exe. Ensure all the files are extracted to the same folder.

  1. No changes are required to the PowerShell script. The only file which you needs to be modified is the CSV file – “UXINPUTFILE.csv”

  2. Open UXINPUTFILE.csv file (in Excel or Notepad).

The CSV file contains the following header columns – uxhostnameorIP,uxusername,uxpassword,backupretentionversions,backupfolder

  1. All the columns are self-explanatory. You can delete the example lines (but DO NOT MODIFY THE HEADERS).

  2. Once you have added the details of the SBC’s save the file as CSV. All fields are mandatory.

To run the script, once the CSV is populated:

You can just right click on the script and click “Run with PowerShell” OR

You can open PowerShell console, browse to script folder and execute script OR

  1. Schedule the script via Task scheduler.

A UXBACKUPLOG.txt log file is created when the script is executed. Make sure to go through this as it will log any errors and also confirm if the backup was successful. The log file is created in the same folder where the script is executed.

Script limitations

One of the biggest security risk I see with the CSV file is the REST account password is in clear text. There isn’t an easy way to encrypt the password for now, but hopefully once we can access the SBC using REST via PowerShell this will change. I would recommend you control the security of the CSV file using restrictive NTFS permissions and enable Auditing on the script folder.

As always please use the script at your own risk!

Follow me

Never Miss a Post. Subscribe Now!

© 2020 by Vik Jaswal @ allthingsUC 

  • Grey Twitter Icon