Forum Discussion
Backup script for F5 LTM and FTP the UCS off to another server
here is the code and below is the error:
!/bin/sh -x Name: backup_cron_scriptv11.sh BIG-IP Backup Script This script automates LTM v11 Backups and saves the files with hostname and date off to an FTP server version 1.0 Author: Bhattman Original Date: 01/07/10 Modified by Yih Wen 30/11/12
tmsh save /sys ucs /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
Added By Ed Elias 11/26/02
export c=$HOSTNAME.$a.crontab export cc=/var/tmp/$c cp /etc/crontab $cc
export MName=xxxxxxx export Log=/var/tmp/log.bigip
export UserName=xxxxx export UserPassword=xxxxxx
Added and Updated by Ed Elias 11/14/07
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
Error I am receiving: command not found: command not found4: " unknown property ': not a valid identifierort: ': not a valid identifierort: ': not a valid identifierort: mv: target\r' is not a directory command not found1: tar: Removing leading /' from member names tar: \r: Cannot stat: No such file or directory tar: Error exit delayed from previous errors ': not a valid identifierort: ': not a valid identifierort: mv: target\r' is not a directory command not found6: command not found8: ': not a valid identifierort: ': not a valid identifierort: cp: target \r' is not a directory : command not found2: ': not a valid identifierort: command not found2: ': not a valid identifierort: ': not a valid identifierort: command not found5: ': not a valid identifierort: ': not a valid identifierort: command not found8: ': not a valid identifierort: ': not a valid identifierort: ': not a valid identifierort: `
- Create directory on BIG-IP /shared/ucs/ as root: mkdir /shared/ucs
- Copy the backup script (backupucs) as root via SCP to /shared/backupucs and make it executable: chmod +x /shared/backupucs
- Create a SSH public keys as root: ssh-keygen -t dsa
- Export the local root public key for remote login on the target / backup server: ssh-copy-id -i ~/.ssh/id_dsa.pub remote_user@your_backup_server
- Modify cron on BIG-IP as root: crontab -e
cron tab for root
1-59/30 * * * * /usr/bin/diskmonitor
00 5 * * * /shared/backupucs
The following script will now be triggered by cron each morning 5 a.m..
A current .ucs file with hostname and timestamp in its name will be created and copied to the target server via SCP.
Files older than 7 days will be deleted.
Don´t forget to modify the passphrase. 😉
As the archive contains the private keys, encrypted export should be mandatory.
\! /bin/bash
time=`date +%Y_%m_%d_%H%M`
unit=`tmsh list sys global-settings one-line | grep -oP '(?<=hostname\s)[^\.]*'`
tmsh save /sys ucs /shared/ucs/autoarchive_${unit}_${time}.ucs passphrase 'topsecret'
scp /shared/ucs/autoarchive_${unit}_${time}.ucs remote_user@your_backup_server:/data/config/loadbalancer/
find /shared/ucs/ -name "autoarchive*" -mtime +7 -ls >> /var/log/ucsdelete
find /shared/ucs/ -name "autoarchive*" -mtime +7 -ls -exec rm -f {} \;
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
