For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Quick and dirty backup script for (v11) F5 LTM

Problem this snippet solves:

>SMTP Configuration

tmsh

modify /sys outbound-smtp mailhub yoursmtpserver.server.com:25

save /sys config

quit

> Execute privileges

chmod +x f5_backup.sh

>Cron job

configure in "crontab -e" or drop in /etc/cron.daily

How to use this snippet:

Uses SSH keys for authentication, here's a good how-to article on setting this up:

[https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server]

Code :

#!/bin/bash
HOSTNAME=$(uname -n)
DATE="$(date +%Y%m%d%H%M%S)"
FILENAME="${HOSTNAME}${DATE}"
function fail {
    echo "$@" | mail -vs "UCS backup failed $HOSTNAME" group@xyz.domain.com
    exit 1
}
tmsh save sys ucs /var/local/ucs/config.ucs
if [ ! -e /root/.ssh/id_rsa ]; then
    fail "Missing SSH Key"
fi
if [ ! -e /var/local/ucs/config.ucs ]; then
    fail "Missing configuration export"
fi
if ! scp -v -i /root/.ssh/id_rsa /var/local/ucs/config.ucs "user@xyz.domain.com:/configs/F5_backups/${FILENAME}.ucs"; then
   fail "Configuration upload failed"
else
  echo "success" |  mail -vs "UCS backup success $HOSTNAME" group@xyz.domain.com
fi
if ! ssh -i /root/.ssh/id_rsa user@xyz.domain.com find /configs/F5_backups/ -mtime +30 -exec rm '{}' \\\;;then
    echo "Backup cleanup failed" | fail
fi
exit 0

Tested this on version:

11.6
Published May 22, 2017
Version 1.0
No CommentsBe the first to comment