cancel
Showing results for 
Search instead for 
Did you mean: 

Stingray Config Backups

SOLVED
mattwater
Contributor

Stingray Config Backups


Has anyone come across a method for automating config backups? searching these forums and the Internet has yielded zip.

I have been trying to use a script I found in a Riverbed University video that demonstrated backup creation via the cli.

You can then SCP to your STM to download the backup.

If I can get it to work I'm hoping to then run the script via a cron job on the STM.

Here is the script


#!/bin/bash


date='date +"%F_%H:%M:%S"'


zxtm=localhost


/opt/zeus/zxtm/bin/zcli << EOF


connect ${zxtm} 9090 admin admin


System.Backups.createBackup "${date}", blah


System.Backups.downloadBackup "${date}", "mystm_${zxtm}_${date}.tar"


EOF


Here is the error I'm getting when I run it :-(


Unexpected ':' found (perhaps you should be putting a name in "quotes") at: ':%M:%S"", "blah...'


Less a name change for the backup I'm creating the script is verbatim from the example

1 ACCEPTED SOLUTION

Accepted Solutions
markbod
Contributor

Re: Stingray Config Backups

Hi Matthew,

You have single quotes (') around the date command when they should be back ticks (`). Alternatively you could use $(). Eg:


date=$( date +"%F_%H:%M:%S" )


The back ticks or $() execute the command in a sub-shell and the result is then stored in the variable. When you use single quotes the literal string (ie the command itself) is being stored in the variable.

Cheers,

Mark

View solution in original post

4 REPLIES 4
markbod
Contributor

Re: Stingray Config Backups

Hi Matthew,

You have single quotes (') around the date command when they should be back ticks (`). Alternatively you could use $(). Eg:


date=$( date +"%F_%H:%M:%S" )


The back ticks or $() execute the command in a sub-shell and the result is then stored in the variable. When you use single quotes the literal string (ie the command itself) is being stored in the variable.

Cheers,

Mark

mattwater
Contributor

Re: Re: Stingray Config Backups

Thank you very much Mark thats great.

As you can see my experience with this sort of thing is shaky at best, the help is very much appreciated.


Success!


"Connected to localhost:9090"


"Wrote 225280 bytes to 'mystm_localhost_2013-02-01_09:04:35.tar'"


I used the tick as "" failed to name the file correctly

Cheers

gael.soude
Occasional Contributor

Re: Stingray Config Backups

Hello,

Here is a small script that will check the disc space available first, then do a backup and then send it to an FTP server.

I would recommend to execute it with crontab

#!/bin/sh

#

# Global variable PATH

exportPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

### Script Variables Definition ###

#

# FTP Server Login/password

USERNAME=""

PASSWORD=""

# FTP Server IP Address

SERVER=""

# FTP server directory

FTPDIR="."

# Working Directory (Checkpoint logs folder)

BACKUPFOLDER="./"

# Backup compressed filename

BACKUPFILE="`date '+%m-%d-%Y'`-`hostname`.tar"

# FTP transfer logs

FTPLOG="backup_ftp.log"

echo

echo"Checking disk space..."

AVAILABLESPACE=`df$BACKUPFOLDER | awk-F" "'END{print $3}'`

echo$AVAILABLESPACE bytes available

# If less than 100Mb available do nothing

if[ 100000 -lt $AVAILABLESPACE ]

then

    echo"Disk space more than 100 Mbytes = OK"

else

    echo"Disk space less than 100 Mbytes = NOT OK"

    exit

fi

echo

echo"Creating backup File"

# Create a backup and save it as a file (and delete it after)

/opt/zeus/zxtm/bin/zcli<< EOF

System.Backups.createBackup "${BACKUPFILE}", backup

System.Backups.downloadBackup "${BACKUPFILE}", "${BACKUPFILE}"

System.Backups.deleteBackups "${BACKUPFILE}"

EOF

echo

echo"Uploading backup file to the FTP server..."

# Send to a FTP server the backup file

cd$BACKUPFOLDER

ftp-inv $SERVER <<EOF > $FTPLOG

user $USERNAME $PASSWORD

mput $BACKUPFILE

quit

EOF

# Check the FTP transfer

FTP_SUCCESS_MSG="226 Transfer complete"

iffgrep"$FTP_SUCCESS_MSG"$FTPLOG ;then

   echo"FTP Transfer OK"

   echo"cleaning files"

   rm$BACKUPFOLDER$BACKUPFILE

   rm./$FTPLOG

   echo"Disk space now available :"

   echo"/ partition : `df $BACKUPFOLDER | awk -F"" 'END{print $3}'` bytes"

   exit

else

   echo"FTP transfer Error: "$OUT

   echo"cleaning files"

   rm$BACKUPFOLDER$BACKUPFILE

   rm./$FTPLOG

   exit

fi

mattwater
Contributor

Re: Stingray Config Backups

Thanks Gael, most helpful.

I do have a working solution in place now.

Cheers