Automated backup F5 configuration to remote server

Problem this snippet solves:

Hi,

I made simple script that auto backup SCF and UCF files to the remote server.

I read great article about autobackup based on the iApp (https://devcentral.f5.com/codeshare/f5-iapp-automated-backup-1114), but I wonder is that way to make it simplest. I don't think that my script is better, but only simple. This scritp based on TFTP communication so it isn't secure.

What you have to do is:

  1. Create a script file on every f5 and place it for example on directory /var/tmp/. I named file script_backup.sh. Change IP address TFTP_SERVER to your remote server

  2. Change mod of file to execute:

    chmod 755 ./script_backup.sh

  3. Add line to the CRONTAB to run this script every X time

    Edit crontab:

    crontab -e

    Add line like this. Of course you can change the time when you want start script, it's only example:

    30 0 * * 6 /var/tmp/script_backup.sh

That's all. I hope you enjoy this script.

I also wonder why f5 don't have native mechanism to auto backup on the remote server. It's the most basic function in other systems.

Code :

TFTP_SERVER=10.0.0.0
DATETIME="`date +%Y%m%d%H%M`"
OUT_DIR='/var/tmp'
FILE_UCS="f5_lan_${HOSTNAME}.ucs"
FILE_SCF="f5_lan_${HOSTNAME}.scf"
FILE_CERT="f5_lan_${HOSTNAME}.cert.tar"
cd ${OUT_DIR}
tmsh save /sys ucs "${OUT_DIR}/${FILE_UCS}"
tmsh save /sys config file "${OUT_DIR}/${FILE_SCF}" no-passphrase
tar -cf "${OUT_DIR}/${FILE_CERT}" /config/ssl
tftp $TFTP_SERVER <<-END 1>&2
mode binary
put ${FILE_UCS}
put ${FILE_SCF}
put ${FILE_CERT}
quit
END
rm -f "${FILE_UCS}"
rm -f "${FILE_SCF}"
rm -f "${FILE_CERT}"
rm -f "${FILE_SCF}.tar"
RTN_CODE=$?
exit $RTN_COD
Updated Jun 06, 2023
Version 2.0

Was this article helpful?

3 Comments

  • The reason there is no auto backup function on a BIG-IP is because that function is done via BIG-IQ Central Management.

  • Where in the tftp server does the script save the backups? I applied the scrip but it doesnt seem to be working

  • One modification required on script

     

    RTN_CODE=$?

    exit $RTN_COD

     

     

    RTN_CODE=$?

    exit $RTN_CODE