CPUG

The Check Point User Group

A Resource For The Check Point Community.  Fast.  Useful.  Independent.

1. Come to CPUG CON 2008 EUROPE in Switzerland on September 8th - 9th!
    Two days full of technical content for Check Point administrators in the beautiful Swiss Alps!
    We already have sign-ups from twelve different countries!
2. CCSA/CCSE One-Week Dual-Certification Training Course with CPUG in San Francisco!
    Courses Starting 7/14, 8/25, 10/6, 11/3, 12/8, (2009) 1/19, 2/9, 3/9, 4/6, 5/4, 6/8, 7/6, 8/3, 9/7.
3. Corrent S3500 SecureXL Turbocards For Sale - Last Six Remaining - Get Your Spares!
4. Join Us On LinkedIn - We now have a CPUG group.


Go Back   CPUG: The Check Point User Group > Check Point Firewall-1/VPN-1 And Related Products > Disaster Recovery
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2008-02-05
rokudan rokudan is offline
Member
 
Join Date: 2008-01-10
Location: Orlando, FL
Posts: 75
Rep Power: 1
rokudan has an average reputation (10+)
Send a message via AIM to rokudan
Default Log Backup/Archive Script

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 {} \;

Last edited by rokudan; 2008-02-06 at 15:42.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 22:18.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0