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 :
#!/bin/bash
# set the date variable
TODAY=$(date +'%Y%m%d')
# Set FTP Remote Hostname or IP
FTPHOST="Your IP"
# FTP User name and password
USER='Your User'
PASSWORD='your password'
# ID Hostname for Backup File
host="$HOSTNAME"
# 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
NUM=0
until [ "$NUM" -eq 5 ]
do
if [ -f /var/local/ucs/$host.ucs ]
then mv $host.ucs $host-$TODAY.ucs ; break
else sleep 5
fi
NUM=`expr "$NUM" + 1`
done
[[ ! -f /var/local/ucs/$host-$TODAY.ucs ]] && exit 1
#Open the FTP connection and move the file
ftp -inv $FTPHOST <<eof user=""><p><b>Tested this on version:</b></p>12.0</eof>