Schedule Cisco UCS Backups

A quick and easy ‘expect’ script that runs from cron on a nightly basis, it’s not the most graceful script you’ll ever see, but it gets the job done.

I understand that scheduled backups are available in Cisco UCS release 2.1

1. Create a ‘backup’ user on the UCS and the remote Unix/Linux Server, in our case we used the VMA as the backup location.

2. Configure passwordless ssh between the UCS and the remote server, more details can be found here.
3. Copy the script below to the remote Linux/Unix server and put it the home directory of the the ‘backup’ user created in step 1.

cat /home/bckup/

#!/usr/bin/expect -f

# Expect script to run full backup of the UCS

# Set Variables

set UCS #UCS VIP Address
set DESTPASSWD ucsb@ckup   
set DESTIP # IP Address of remote Unix/Linux Server
set DESTUSER backupuser
set DESTDIR /var/ftp/pub/ucsbackups/

 # Connect to UCS

spawn ssh $UCS

# Delete previous night backup as UCS allows only one object to exist

 send   “scope system\n”

send   “delete backup $DESTIP\n”

send   “commit-buffer\n”

send   “exit\n”

# Run New Backup and SCP to the shared area on the VMA

 send   “scope system\n”

send   “create backup scp://$DESTUSER@$DESTIP$DESTDIR full-state enabled \n”

expect “Password:”

send   “$DESTPASSWD\n”

send   “commit-buffer\n”

send   “exit\n”

expect  eof

4. Edit the crontab of the ‘backup’ user and schedule it to run on Sunday morning at 3am.

crontab -l
0 3 * * 7 /home/bckup/ > /home/bckup/full.txt

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s