Recently i faced some challenges in creating “automatic backup script” for F5 LTM, the main reason for this was because i am not a regular scripting guy, and F5 TAC doesn’t support these kind of things. I was initially shocked when i heard from F5 TAC that they cannot do such scripting, and the only forum where i can get any help is F5 devcentral community. Although i have posted my query there and few people tried to help me ,however at last it was not fruitful at all. So, I thought of sharing my experience here, so that people can get benefited and not face any unnecessary hassle.

This Backup is used to recover the device from complete crash down situation.

These are the three kind of files you can get,with date appended after your device hostname , if you have successful running script.

Backup

Important points to consider when you make your own backup script :-

1.Do not use windows notepad to edit this script. You will end up messing lot of things. This script is a Shell script so i would suggest to use VI editor to edit anything in the script.

2.After editing , use WinSCP to upload or download anything to and from the F5 LTM device.

3.Transfer your script by WinSCP under “/etc/cron.daily” if you want daily backup, else select other folder available within the “/etc” folder starting from word “cron”.

4.Now login to F5 LTM CLI , and type in “cd /etc/cron.daily” to get into that folder. You can see all available files with “ll” command in that folder.

5.Issue “sh -x  backup_cron_scriptv10.sh” command to check for any errors, if any error found carefully read the output. If you want to change anything in script , simply type “vi backup_cron_scriptv10.sh” you will get into VI editor mode. You can find VI editor commands online by googling around. You can insert anything by “i” and quit by “:wq” command.

6.If script runs well, then you can see all three files inside your FTP server. Now make it run daily by “chmod 777 backup_cron_scriptv10.sh” command.

 

Below is the script, you only need to edit FTP ip address , username and password according to your environment:-

date
# Automatic Backup Script for F5 LTM V10″backup_cron_scriptv10.sh”
#Author “Afroz Ahmad”
b config save /var/tmp/BIG-IP_backup.ucs
export a=`date +”%y%m%d”`
export aa=”$HOSTNAME.$a.ucs”
export b=”/var/tmp/$aa”
mv /var/tmp/BIG-IP_backup.ucs $b

tar -cf /var/tmp/certs.tar /config/ssl
export ff=”$HOSTNAME.$a.certs.tar”
export f=”/var/tmp/$ff”
mv /var/tmp/certs.tar $f

export c=”$HOSTNAME.$a.crontab”
export cc=”/var/tmp/$c”
cp /etc/crontab $cc

export MName=192.168.0.1
export MDir=/F5/
export Log=/var/tmp/log.bigip

export UserName=admin
export UserPassword=password

export Machine1f2=$aa
export Machine1f3=$c
export Machine1f4=$ff

ftp -nvd ${MName} <<-END 1>&2 > ${Log}
user ${UserName} ${UserPassword}
bin
dir
put ${b} ${MDir}${Machine1f2}
put ${cc} ${MDir}${Machine1f3}
put ${f} ${MDir}${Machine1f4}
quit
END

rm -f ${b}
rm -f ${cc}
rm -f ${f}
RTN_CODE=$?

exit $RTN_CODE