Forum Discussion
F5 Ltm Backup Script
Hello Experts,
Reference:- https://devcentral.f5.com/wiki/AdvDesignConfig.LTM_Backup_Shell_Script.ashx I have taken reference from above URL and modified and have used below script to take backup of F5 , however the backup is not working/coming to FTP. I am not much of a script guy , so can anyone suggest me, what i am doing wrong in here. Also i want to know at which time this script will execute. Much appreciated.
!/bin/sh -x Name: backup_cron_scriptv10.sh BIG-IP Backup Script This script automates LTM v10 Backups and saves the files with hostname and date off to an FTP server version 1.0 Author: Bhattman Original Date: 01/07/10 Backup your config in ucsb config save /var/tmp/BIG-IP_backup export a=
date +"%y%m%d"
export aa=$HOSTNAME.$a.ucs
export b=/var/tmp/$aa
mv /var/tmp/BIG-IP_backup.ucs $b
Backup the SSL Certs
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
copy your crontab information - it can be other files as wellexport c=$HOSTNAME.$a.crontab export cc=/var/tmp/$c cp /etc/crontab $cc
export MName=<192.168.1.100/F5> export Log=/var/tmp/log.bigip
ftp username and passwordexport UserName=admin export UserPassword=admin
export Machine1f2=$aa export Machine1f3=$c export Machine1f4=$ff
ftp command that sends the files over to ftp serverftp -nvd ${MName} <<-END 1>&2 > ${Log} user ${UserName} ${UserPassword} bin put ${b} ${Machine1f2} put ${cc} ${Machine1f3} put ${f} ${Machine1f4} quit END
removes the copied files after pushrm -f ${b} rm -f ${cc} rm -f ${f} RTN_CODE=$?
exit $RTN_CODE
6 Replies
- cjunior
Nacreous
I understood your problem and your BIG-IP version is in 10.x correct? The problem may lie in "export MName". Can you post again the script in code format? To do this, each line needs to start with four blank spaces. See in "how to format". tks - Afroz_Ahmad_114
Nimbostratus
Yes version is 10.x. I intentionally put "export MName <192.168.1.100/F5> because i wanted all my FTP related files to go under F5 folder only. However i have tried with "export MName <192.168.1.100> it didn't work either. Other steps that i did after creating script. Created a file called backup_cron_scriptv10.sh in /etc/cron.daily, and executed by chmod 775 "backup_cron_scriptv10.sh" Below is the script. b config save /var/tmp/BIG-IP_backup 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.1.100/F5> export Log=/var/tmp/log.bigip export UserName=admin export UserPassword=admin export Machine1f2=$aa export Machine1f3=$c export Machine1f4=$ff ftp -nvd ${MName} <<-END 1>&2 > ${Log} user ${UserName} ${UserPassword} bin put ${b} ${Machine1f2} put ${cc} ${Machine1f3} put ${f} ${Machine1f4} quit END rm -f ${b} rm -f ${cc} rm -f ${f} RTN_CODE=$? exit $RTN_CODE - cjunior
Nacreous
Hi, You can test this version now? at the moment I am unable. I added a field "MDir" to define your target directory. If that does not work let me fix that for you. Tks
!/bin/sh -x Name: backup_cron_scriptv10.sh BIG-IP Backup Script This script automates LTM v10 Backups and saves the files with hostname and date off to an FTP server version 1.0 Author: Bhattman Original Date: 01/07/10 b config save /var/tmp/BIG-IP_backup 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.1.100 export MDir=/F5/ export Log=/var/tmp/log.bigip export UserName=admin export UserPassword=admin export Machine1f2=$aa export Machine1f3=$c export Machine1f4=$ff ftp -nvd ${MName} <<-END 1>&2 > ${Log} user ${UserName} ${UserPassword} bin 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 - swo0sh_gt_13163
Altostratus
Dear all,
How can I have the same script for SCP server instead FTP? A little urgent, if someone can look into this.
Cheers!
- mElhoussini_204
Nimbostratus
hi,
how can we use SCP ?
- Brad_Parker
Cirrus
This is how I've done it via SFTP and key authentication. You need to first create a dsa key to use for authentication to your SCP/SFTP server. Then put the script in a file named /config/backup and create a chron job using this,
chmod +x /config/backup; ln -s /config/backup /etc/cron.daily/backup!/bin/bash Set variables for UCS file name dt=`date +%Y%m%d` hostname=`uname -n |cut -d. -f1` DDIR=/var/tmp SFTPhost= Delete old ucs file created by this script rm $DDIR/$hostname*.ucs Send syslog message to log servers logger -p local0.info -t BIGIP configuration backup started. Commit configuration from memory to files cd /config tmsh save /sys config Create configuraiton archive tmsh save /sys ucs $DDIR/$hostname-$dt.ucs Send to admin server via SFTP cd $DDIR sftp -oIdentityFile=/config/sftp_dsa $hostname@$SFTPhost<< EOF cd $hostname put $hostname-$dt.ucs quit EOF Send syslog message to log servers logger -p local0.info -t BIGIP configuration backup completed.
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