Forum Discussion
Automatic backup of BIGIP LTM
Can Anybody suggest me how to take automatic backup in BIG IP LTM v11.2? I want to take weekly backup of system configuration automatically .
Pls help on this .
35 Replies
- Indrajit_Basak_
Nimbostratus
Hi , I have configured 00 3 * * * tmsh save /sys ucs /var/ucs/XYZ. ucs in crontab for automatically store the UCS backup file in F5 .
Now pls let me know step by step procedure for automated FTP Backup
- Indrajit_Basak_
Nimbostratus
Can Anybody help on this ?
- Thomas_Gobet_91
Cirrostratus
You just have to make some changes on the script upper.
What you did before might not be good, because you're going to erase each occurrence of your UCS file (because it will always have the same name).With my script below, your UCS will have the date as filename.
Here it is :
!/bin/bash $DATE=`date "+%m_%d_%y"` Here we create the ucs archive tmsh save sys ucs $DATE Here we do the same with ftp ftp -n your_server <What you have to define is : Your_Username, Password and Backup_Directory- Indrajit_Basak_
Nimbostratus
Thanks a lot Thomas . So after writing this script in bash shell how to run it in crontab . I want weekly backup ( Means backup will happen every thrusday at 3 AM automatically and transfer to FTP Server . Can you pls help on that
- Thomas_Gobet
Nimbostratus
You just have to make some changes on the script upper.
What you did before might not be good, because you're going to erase each occurrence of your UCS file (because it will always have the same name).With my script below, your UCS will have the date as filename.
Here it is :
!/bin/bash $DATE=`date "+%m_%d_%y"` Here we create the ucs archive tmsh save sys ucs $DATE Here we do the same with ftp ftp -n your_server <What you have to define is : Your_Username, Password and Backup_Directory- Indrajit_Basak_
Nimbostratus
Thanks a lot Thomas . So after writing this script in bash shell how to run it in crontab . I want weekly backup ( Means backup will happen every thrusday at 3 AM automatically and transfer to FTP Server . Can you pls help on that
- Thomas_Gobet_91
Cirrostratus
In crontab, you have 2 options :
The first one is to add your script in : /etc/cron.weekly/
The second one is to add a line in /etc/crontab like that :0 4 * * 0 Your_scriptIt will run your script every week (on Sunday) at 4am.
- Sugraman_297082
Nimbostratus
Hi I know its a old post, but thought of asking since this procedure is not creating the ucs file. below is what i have done. Not sure what i am missing here.
[root@lb-1a:Active:In Sync] cron.hourly more ucs.sh
!/bin/bash$DATE=
date "+%m_%d_%y"tmsh save sys ucs $DATE.ucs
[root@lb-1a:Active:In Sync] etc more crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
HOME=/
run-parts01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthy
01 * * * * root ucs.sh
- Thomas_Gobet
Nimbostratus
In crontab, you have 2 options :
The first one is to add your script in : /etc/cron.weekly/
The second one is to add a line in /etc/crontab like that :0 4 * * 0 Your_scriptIt will run your script every week (on Sunday) at 4am.
- Sugraman_297082
Nimbostratus
Hi I know its a old post, but thought of asking since this procedure is not creating the ucs file. below is what i have done. Not sure what i am missing here.
[root@lb-1a:Active:In Sync] cron.hourly more ucs.sh
!/bin/bash$DATE=
date "+%m_%d_%y"tmsh save sys ucs $DATE.ucs
[root@lb-1a:Active:In Sync] etc more crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
HOME=/
run-parts01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthy
01 * * * * root ucs.sh
- Mahmoud_Eldeeb_
Cirrostratus
I prefer to go with Config Backup for F5 utility its a VM appliance with GUI interface and very easy to manage.find it in below link http://sourceforge.net/projects/f5configbackup/ - Mahmoud_Eldeeb_
Cirrostratus
I prefer to go with Config Backup for F5 utility its a VM appliance with GUI interface and very easy to manage.find it in below link http://sourceforge.net/projects/f5configbackup/
- Shann_P_160848
Nimbostratus
We use this too. Extremely easy setup and very good documentation.
- bcrogerz
Cirrus
suggest to get an Manager Software like AppViewX or EM or Big iQ for basic maintenance of the F5s
- oshaughnessy_19
Nimbostratus
I wrote a script to run "tmsh save /sys ucs" on each of a set of LTMs, download the resulting archive, then expand it and store the changes in git. Here's a copy of it, cleaned up for distribution a little bit.
!/bin/sh f5-backup: create UCS backups of a list of BIG-IP F5 devices (most likely Local Traffic Managers, aka LTMs) See https://support.f5.com/kb/en-us/solutions/public/13000/100/sol13132.html Author: O'Shaughnessy Evans, 2015-09 trap sigdie INT QUIT umask 022 safety checks: exit on unset variables and errors, don't expand * set -o nounset set -o errexit set -o noglob ME=${0*/} HOSTS=${*:-"FIX: put your default hosts here"} BACKUP_DIR=$HOME/var/f5 BACKUP_USER=rancid REMOTE_TMPDIR=/var/tmp sigdie() - Signal handler that reports the cause of death (barely) function sigdie { die $EX_OSERR "killed" } Make sure we're running as the intended backup user. This ensures that ssh always runs under the same conditions and that directories relative to $HOME are always the same. if [[ "$USER" != "$BACKUP_USER" ]]; then echo "fatal error: running as $USER; please invoke as $BACKUP_USER" >&2 exit 2 fi remote_backup=$REMOTE_TMPDIR/backup-$(date +%F).ucs for host in $HOSTS; do local_backup=$host-$(date +%F).tar.gz cd $BACKUP_DIR [[ -d $host ]] || mkdir $host cd $host echo " Creating UCS backup for $host" echo "" echo " tmsh save /sys ucs ..." ssh $host tmsh save /sys ucs $remote_backup 2>&1 |sed 's,^, tmsh save: ,' echo "" echo "* Downloading" echo "" echo " $remote_backup -> $local_backup" scp -o 'StrictHostKeyChecking no' -q $host:$remote_backup $local_backup 2>&1 |sed 's,^, scp: ,' gunzip -c $local_backup |tar xf - rm $local_backup echo "" echo "* Saving change in Git" echo "" git add . |sed 's,^, git-add: ,' git commit -m"$ME: automated backup of $host at $(date)" |sed 's,^, git-commit: ,' git push 2>&1 |sed 's,^, git-push: ,' echo "" doneYou'll want to change a few things:
- Where you see "FIX: put your default hosts here", replace it with a space-separated list of the hostnames you're backing up. Alternatively, you can pass the list of hostnames on the command line when you run the script.
- Assign the username of the user ID you're running the backup script as to
.BACKUP_USER - Assign the directory where you want to maintain your git repo to
.BACKUP_DIR
I wrote it assuming that
has a shell account on the F5 that can be accessed with its ssh key. If you don't have one, create an account with "advanced shell" permissions and "Resource Administrator" rights, then generate an ssh key for it on the host where this script will run (e.g.$BACKUP_USER
), then copy the public key tossh-keygen -t rsa -b 2048
on each of the F5s you want to back up. You'll also need to enable the user of an authorized keys file if you haven't done so. See SOL13454: Configuring SSH host-based authentication on BIG-IP systems (11.x) for more details.~/.ssh/authorized_keysYou'll want to initialize
as a git repository, too. The script will git-add, commit, and push any changes between runs, so if you set a remote repository as your origin, you'll get a changelog on your Git server. It's very convenient.$BACKUP_DIRTo recover with the contents of this repository, you would need to check out the repo, remove the .git subdir, then tar it up and gzip it. The result should be the same as the last
that was run on that server. I should add that I haven't tested a restore from this, though, and that should be a real big caveat here. So... buyer beware :^)tmsh save /sys ucs
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com