Audiocodes SBC – Backup INI file using Python Script

Audiocodes SBC – Python script to backup INI file on daily basis

In this post we are going to check how to backup Audiocodes SBC INI file using Python Script.  In a normal scenario, if you need to backup Audiocodes as an when required, you can use GUI / web portal to backup the INI file. But it becomes cumbersome task if you need to do it on daily basis. In such cases, you can make use of automation and get your backup completed automatically.

Here is the python script to backup Audiocodes SBC INI file.

import requests
from requests.auth import HTTPBasicAuth
from datetime import datetime
import pytz

##IGNORE SSL WARNING###
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
#######################

###GETTING TIME IN IST FORMAT####
IST = pytz.timezone('Asia/Kolkata')
datetime_ist = datetime.now(IST)
current_datetime = datetime_ist.strftime('%d%m%Y_%H%M')
#######################

##AUDIOCODES SBC IP ADDRESS##
url = "192.168.1.181"
#######################

###MAKING GET REQUEST###
response = requests.get('https://' +url+ '/api/v1/files/ini', auth = HTTPBasicAuth('backup', 'backup'), verify=False)
  
if response.status_code == 200:
    with open(url + "_" + current_datetime + "_backup.ini", "w") as f:
        f.write(response.text)
        f.close()
        print("Successfully backed up the INI file")
else:
    print("Backup has been failed with an error status of",response.status_code)
    print("Error Description is: ", response.text)

#######################

 

All you need to do now is run the python using using task scheduler / cron task so that it will be triggered on daily/weekly basis and get your job done.

You can also watch the YouTube video for more explanation on the Python script.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *