Forum Discussion

Suresh_Jo_32729's avatar
Suresh_Jo_32729
Icon for Nimbostratus rankNimbostratus
Aug 02, 2018

Auto back script in cron shell

All,

 

I have deployed one script in ltm running in 12.1.2 for auto backup in cron shell. I am not getting the desired result. Can someone pls check and let me know what corrections are required in the script.

 

Script:

 

vi backup.sh

 

!/bin/bash

daily_backup.sh HOST=$HOSTNAME DATE=date +%m%d LDIR="/var/local/ucs/" DDIR="/var/local/ucs/daily/" tmsh save sys ucs $LDIR$HOST.ucs mv $LDIR$HOST.ucs $DDIR$HOST.$DATE.ucs /usr/bin/find /var/local/ucs/daily/ -mtime +45 -exec rm {} \; USER=xxxx PASS=xxxx cd $DDIR ftp -nv xxxx.com exit 1

 

and then add the crontab -e command and add in this line 20 23 * * * bash /var/scripts/daily_backup.sh

 

Also how I can check if the config file is generating in ltm locally?

 

4 Replies

  • vi backup.sh

     

    !/bin/bash

    daily_backup.sh HOST=$HOSTNAME DATE=date +%m%d LDIR="/var/local/ucs/" DDIR="/var/local/ucs/daily/" tmsh save sys ucs $LDIR$HOST.ucs mv $LDIR$HOST.ucs $DDIR$HOST.$DATE.ucs /usr/bin/find /var/local/ucs/daily/ -mtime +45 -exec rm {} \; USER=xxxxx PASS=xxxx, cd $DDIR ftp -nv xxxx.com<< SCRIPT quote USER $USER quote PASS $PASS bin cd $HOST put $HOST.$DATE.ucs quit SCRIPT exit 1

     

    and then add the crontab -e command and add in this line 20 23 * * * bash /var/scripts/daily_backup.sh

     

  • don't use crontab but icall

    tmsh create sys icall script backup
    tmsh modify sys icall script backup definition { exec /var/scripts/daily_backup.sh }
    tmsh create sys icall handler periodic backup-handler first-occurrence 2017-07-21:00:00:00 interval 604800 script backup
    tmsh save sys config