Forum Discussion

Andy_Pelletier_'s avatar
Andy_Pelletier_
Icon for Nimbostratus rankNimbostratus
Sep 18, 2008

Script to automate config backup on LTM 9.2

I would like to create/import a script and use cron to automate the creation of a .ucs file on my F5-LTM 9.2 devices.

 

 

Within the script, I would like for the newly generated file to created with the date stamp in the file name.

 

Finally, I would like the script to then FTP the new .ucs file to a remote ftp server.

 

 

I see that when I SSH to the device, and run "config save filename" the result is different from running the same command in the Console "BIGpipe" window.

 

 

From SSH, it launches a "wizard" to walk thru the setup of the device. From Console BIGpipe, it successfully creates the .ucs file.

 

 

Can someone tell me how to create the .ucs file while SSH'd to the device, please.

 

 

Best regards.

6 Replies

  • the GUI assumes the leading keyword "bigpipe". If you ssh in as root instead of the shell, you need b config save filename
  • Would you be willing to share the CRON job that you created? This is also something I'm looking to do, but don't know alot about scripting.
  • This is a script that I have been using for some time now. I placed it in /etc/cron.weekly and it creates a date stamped tarball of the .UCS file and FTPs it to a remote server. Been running it for well over 2 years. The only issue is when you upgrade you will have to put the script back in /etc/cron.weekly.

     

    You will need to change the ftphost, user and password variables to reflect the FTP server you are connecting to as well as change the directory down below where the script has cd /F5/JAX1 to reflect the clients directory structure.

     

     

    !/bin/bash

     

    set the date variable

     

    today=$(date +'%Y%m%d')

     

    ftphost="ADD FTP IP HERE"

     

    user="ADD FTP USERNAME HERE"

     

    password="ADD FTP PASSWORD HERE"

     

    run the F5 bigpipe config builder

     

    cd /

     

    bigpipe config save /config.ucs

     

    Rename the config.ucs and append the date to the end

     

    NUM=0

     

    until [ "$NUM" -eq 5 ]

     

    do

     

    if [ -f /config.ucs ]

     

    then mv config.ucs config-$today.ucs ; break

     

    else sleep 5

     

    fi

     

    NUM=`expr "$NUM" + 1`

     

    done

     

    [[ ! -f /config-$today.ucs ]] && exit 1

     

    Open the FTP connection and move the file

     

    ftp -in < open $ftphost

     

    user $user $password

     

    bin

     

    cd F5/JAX1

     

    put config-$today.ucs

     

    close

     

    bye

     

    EOF

     

    Delete the backedup config file.

     

    rm -rf config-$today.ucs

     

     

    let me know if you have any questions
  • I put this out in the wiki. Thanks dwertz for contributing to the community!

     

     

    http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/BIG-IPBackupScriptInBash.html Click here