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:
-
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
-
Change mod of file to execute:
chmod 755 ./script_backup.sh
-
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
Is there any reason not using this?
Archiving UCS files using the logrotate and crontab utilities (11.x - 17.x) (f5.com)
@Alex: Take a look - This is what Im using for backup per scp to remote
- Alex_MadjeskiAltocumulus
P_KueppersThank you for such a quick response! It would be easier to use the TFTP but policy mandates to do it by secure means.
- Alex_MadjeskiAltocumulus
Thank you for sharing this.
How can I modify this script to use SCP?
- Madharasan_VictNimbostratus
One modification required on script
RTN_CODE=$?
exit $RTN_COD
RTN_CODE=$?
exit $RTN_CODE
- NdlovummCirrus
Where in the tftp server does the script save the backups? I applied the scrip but it doesnt seem to be working
- David_WillmanEmployee
The reason there is no auto backup function on a BIG-IP is because that function is done via BIG-IQ Central Management.