BASH Script to make UCS and FTP off to remote Server

Problem this snippet solves:

Automate UCS Backup and copy via FTP to remote FTP Server.

How to use this snippet:

Run as a script to save and ship off a UCS file, via FTP, from the BIGIP Device to a Remote Server.

Code :

# set the date variable
TODAY=$(date +'%Y%m%d')

# Set FTP Remote Hostname or IP

# FTP User name and password
USER='Your User'
PASSWORD='your password'

# ID Hostname for Backup File

# Used to identify the first 3 letters of the hostname which can be
# to separted backups on the remote FTP Server by Site ID or Device ID
folder=$(echo $HOSTNAME -s|cut -c 1-3)

#run the F5 bigpipe config builder
cd /var/local/ucs
tmsh save sys ucs /var/local/ucs/$host.ucs
#Rename the config.ucs and append the date to the end
until [ "$NUM" -eq 5 ]
if [ -f /var/local/ucs/$host.ucs ]
then mv $host.ucs $host-$TODAY.ucs ; break
else sleep 5
NUM=`expr "$NUM" + 1`
[[ ! -f /var/local/ucs/$host-$TODAY.ucs ]] && exit 1

#Open the FTP connection and move the file
ftp -inv $FTPHOST <

Tested this on version:

Published Jun 08, 2016
Version 1.0

Was this article helpful?