06 Feb

Automating Cisco TelePresence MCU backups

I’m responsible for managing a few Cisco TelePresence MCUs in my role, we have various models, 4210, 4505, 8510 and 8710’s.  I wanted a clean (and dirty) way to backup the cdr log and configuration without using TMS, my method uses FTP and the API.

I have a shell script configured to download the two xml files via FTP then launch a PHP script to clear the cdr log.


#!/bin/sh
USERNAME="mcu.username"
PASSWORD="mcu.password"
SERVER="ip.or.dnsname.com"
CDRNOW=$(date +"%d%m%Y")_cdr_log.xml
CONFNOW=$(date +"%d%m%Y")_configuration.xml

# remote files to download
CDRFILE="cdr_log.xml"
CONFFILE="configuration.xml"

# local directory to download files to
BACKUPDIR="/path/to/backup"

# login to remote server
cd $BACKUPDIR
ftp -ni <<EOF
open $SERVER
user $USERNAME $PASSWORD
get $CDRFILE
get $CONFFILE
close
bye
EOF

# move files
mv $CDRFILE $CDRNOW
mv $CONFFILE $CONFNOW

# delete cdr logs
php /path/to/php/script/delete.cdr.script.php
exit

Then the PHP script is launched to clear the cdr log, the PHP script relies on the XMLRPC library available at http://phpxmlrpc.sourceforge.net/

<?php
require_once('xmlrpc/xmlrpc.inc');
$request = xmlrpc_encode_request("cdrlog.query", array (
        "authenticationUser"=>"mcu.username",
        "authenticationPassword"=>"mcu.password"
        ));
$context = stream_context_create(array('http' => array(
        'method' => "POST",
        'header' => "Content-Type: text/xml",
        'content' => $request
)));
$file = file_get_contents("http://ip.or.dnsname.com/RPC2", false, $context);
$response = xmlrpc_decode($file);
if (!$response) {
        print "<p>Could not connect to HTTP server.</p>";
} elseif (xmlrpc_is_fault($response)) {
        print "<p>XML-RPC Fault #" . $response[faultCode] . ": " .
                $response[faultString];
} else {
$deletableIndex = $response[deletableIndex];

$request2 = xmlrpc_encode_request("cdrlog.delete", array (
        "authenticationUser"=>"mcu.username",
        "authenticationPassword"=>"mcu.password"
        "deleteIndex"=>$deletableIndex
        ));
$context2 = stream_context_create(array('http' => array(
        'method' => "POST",
        'header' => "Content-Type: text/xml",
        'content' => $request2
)));
$file2 = file_get_contents("http://ip.or.dnsname.com/RPC2", false, $context2);
$response2 = xmlrpc_decode($file2);
if (!$response2) {
        print "<p>Could not connect to HTTP server.</p>";
} elseif (xmlrpc_is_fault($response2)) {
        print "<p>XML-RPC Fault #" . $response2[faultCode] . ": " .
                $response2[faultString];
} else {
print_r($response2);
exit;
}
}
?>

A cron job is added to run the script on a monthly basis

@monthly /path/to/backup/script/backup.sh >/dev/null 2>&1

Bear in mind these are dirty scripts, the code could obviously be optimised but they serve the purpose!

  • crazyhorse

    Hi techy, this looks quite nifty. Can this approach also be used to auto-backup the configuration.xml file from a Cisco VCS box? Thanks.

    • I’ll post another one shortly for the VCS, I tried it with this method but the VCS is quite touchy with its SSH keys and I couldn’t enable telnet at the time!
      /Daz

    • darrengoulden

      I’ll post another one shortly for the VCS, I tried it with this method but the VCS is quite touchy with its SSH keys and I couldn’t enable telnet at the time!
      /daz

      • crazyhorse

        Thanks, Daz. I have tried mucking about with scripting using SCP, but it gets just oh-so-convoluted and unwieldy that it…just…sucks! I also read somewhere about possibilities using SecureCRT, but haven’t got around it. Thing is, it is very frustrating that a standard automated backup for the VCS does not exist from Cisco – kinda makes the video story look weak to my customers. Look forward to your post. Great work!

        • darrengoulden

          I agree, I recently had a VCS go faulty, was amazed when the TAC engineer told me my TMS backup of the VCS didn’t include a full configuration backup!!

        • darrengoulden

          I’ve just published this bud, hope it helps you out wp.me/p2db3V-4v

  • Pingback: Automate Cisco Video Communication Server configuration backups()

  • Rachid

    Please note that you should not download (large) files via HTTP or FTP.

    From software version 4.4 this is also in stated on the web interface: “Caution: Only backup configuration when the unit is not hosting active calls”.
    And also in the release notes:

    “Uploading and downloading large files while heavily loaded

    We recommend that you do not upload or download large files from the MCU while it is hosting active calls.
    Files such as CDRs, audit logs and code images should be transferred when there are few or no calls on the”

    Cisco is not entirely clear about why this is causing issues, but I suggest we listen to Cisco in this 🙂