Having moved my mgmt server from Windows, to SecurePlatform, I had to write some scripts for backing things up. I have a few more scripts to write, but thought I would share this one with everyone. It will take the previous days log files, compress and archive them into a gzip, ftp them to a server, then cleanup old logs and gzips.. The below is pretty self explanatory, but if ya have any questions I might be able to help.
Works on SecurePlatform, but probably would on IPSO and other *nix platforms as well... Make sure to chmod 777 after you are done in vi.
Note, the way I have things setup... In your home ftp dir you need to have created the path hostname/logs, replace hostname of course with whatever yours is...
Code:
# !/bin/sh
# Define string variables!
hostname=`hostname`
ftp_server="1.1.1.1"
ftp_username='windowsdomain\\username'
ftp_password=password123
cpdir=/opt/CPshrd-R62
localbakdir=/var/opt/CPsuite-R62/fw1/log/
remotebakdir=${hostname}/logs/
logdate=`/bin/date --date="yesterday" +%Y-%m-%d`
logname=${logdate}
archivedate=`/bin/date --date="yesterday" +%Y_%m_%d`
archivename=logs_${hostname}_${archivedate}
# Set Check Point profile for library settings!
. $cpdir/tmp/.CPprofile.sh
# Archive yesterday`s log files!
cd ${localbakdir}
/bin/tar zcf ${localbakdir}${archivename}.tgz ${logname}*
# FTP files to backup server!
ftp -in $ftp_server <<EOC
user ${ftp_username} ${ftp_password}
binary
cd ${remotebakdir}
lcd ${localbakdir}
put ${archivename}.tgz
bye
EOC
# Remove archive files older than 14 days from local disk!
/usr/bin/find ${localbakdir}/*".tgz" -mtime +14 -exec /bin/rm {} \;
# Remove log files older than 14 days from local disk!
/usr/bin/find ${localbakdir}/*".log" -mtime +14 -exec /bin/rm {} \;
/usr/bin/find ${localbakdir}/*".logaccount_ptr" -mtime +14 -exec /bin/rm {} \;
/usr/bin/find ${localbakdir}/*".loginitial_ptr" -mtime +14 -exec /bin/rm {} \;
/usr/bin/find ${localbakdir}/*".logptr" -mtime +14 -exec /bin/rm {} \;