CPUG: The Check Point User Group

Resources for the Check Point Community, by the Check Point Community.


Tim Hall has done it again! He has just released the 2nd edition of "Max Power".
Rather than get into details here, I urge you to check out this announcement post.
It's a massive upgrade, and well worth checking out. -E

 

Results 1 to 17 of 17

Thread: Schedule migrate export

  1. #1
    Join Date
    2014-05-09
    Posts
    3
    Rep Power
    0

    Default Schedule migrate export

    Hi,

    As i didn't find anything using google, i made a script that could be use in order to schedule an upgrade export (each week for example), and backup files to an ftp server :

    Those variables must be change; adjust according to your Checkpoint and FTP configuration :
    • HOST
    • USER
    • PASSWD


    • Create the script export.sh into /usr/local/bin folder :


    Paste this content into export.sh (don't forget to adapt:
    Code:
    #!/bin/bash -f
    source /etc/profile.d/CP.sh
    
    #VARIABLES
    DATE=`date +%Y%m%d`
    FILE=$HOSTNAME"_"$DATE"_export"
    FOLDER=$FWDIR/bin/upgrade_tools/
    
    echo ******Process Migrate Export `date +'%d.%m.%y %H:%M:%S'` STARTED******
    
    
    echo Migrate export $FILE started
    #UPGRADE_EXPORT
    echo File will be $FOLDER$FILE.tgz
    $FWDIR/bin/upgrade_tools/migrate export -n $FOLDER/$FILE
    echo Migrate export $FILE finished
    
    #Waiting for migrate export to finished
    echo  waiting 2  minutes
    sleep 2m
    echo waiting finished
    
    
    echo FTP $FILE  started
    #FTP
    cd $FOLDER
    HOST=HOST
    USER=USER
    PASSWD=PASSWD
    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    bin
    put $FILE.tgz
    quit
    END_SCRIPT
    
    echo FTP $FILE finished
    
    #REMOVE
    echo Remove of  $FOLDER/$FILE.tgz started
    
    rm $FWDIR/bin/upgrade_tools/$FILE.tgz
    
    echo Remove of  $FOLDER/$FILE.tgz finished
    
    echo ******Process Migrate export `date +'%d.%m.%y %H:%M:%S'` FINISHED******
    
    exit
    
    #Script written by Sebastien GUILMER
    • Make the script executable :


    chmod +x export.sh

    • Modify the crontab :

    crontab –e
    • Paste the line (don't forget to adapt) :

    * * * * 0 /usr/local/bin/export.sh >> /usr/local/bin/CRONexport.txt

    The script running without error give that :

    Code:
    [Expert@Mgmt:0]# ./export.sh
    ******Process Migrate Export 09.05.14 14:22:26 STARTED******
    Migrate export Mgmt_20140509_export started
    File will be /opt/CPsuite-R77/fw1/bin/upgrade_tools/Mgmt_20140509_export.tgz
    Migrate export Mgmt_20140509_export finished
    waiting 2 minutes...
    waiting finished
    FTP Mgmt_20140509_export started
    FTP Mgmt_20140509_export finished
    Remove of /opt/CPsuite-R77/fw1/bin/upgrade_tools//Mgmt_20140509_export.tgz started
    Remove of /opt/CPsuite-R77/fw1/bin/upgrade_tools//Mgmt_20140509_export.tgz finished
    ******Process Migrate export 09.05.14 14:23:28 FINISHED******
    [Expert@Mgmt:0]#
    Try this in lab before deploying in production !

    Best regards,

    Sébastien G
    Last edited by Sebastieng; 2014-05-12 at 12:00.

  2. #2
    Join Date
    2011-08-02
    Location
    http://spikefishsolutions.com
    Posts
    1,652
    Rep Power
    10

    Default Re: Schedule migrate export

    just a quick FYI. You can source

    /etc/profile.d/CP.sh

    Then you don't need to change the script everytime you upgrade. I would also put the script in a private dir outside of the checkpoint dirs so that the script location wouldn't change after and upgrade as well.

    nice script!

  3. #3
    Join Date
    2014-05-09
    Posts
    3
    Rep Power
    0

    Default Re: Schedule migrate export

    Quote Originally Posted by jflemingeds View Post
    just a quick FYI. You can source

    /etc/profile.d/CP.sh

    Then you don't need to change the script everytime you upgrade. I would also put the script in a private dir outside of the checkpoint dirs so that the script location wouldn't change after and upgrade as well.

    nice script!
    Hi jflemingeds,

    Thank for the information, it's very usefull !

    So i can put the script in the home directory of admin, right ?

  4. #4
    Join Date
    2011-08-02
    Location
    http://spikefishsolutions.com
    Posts
    1,652
    Rep Power
    10

    Default Re: Schedule migrate export

    I'm not a fan of scripts in the home dir. I think /usr/local/bin would be a good idea, but really its up to you.

  5. #5
    Join Date
    2014-05-09
    Posts
    3
    Rep Power
    0

    Default Re: Schedule migrate export

    Thank you,

    I have edited my post with the "best practice" provided :-), Thank you !

  6. #6
    Join Date
    2012-08-16
    Posts
    182
    Rep Power
    8

    Default Re: Schedule migrate export

    The script looks great, I went to test it after plugging in the appropriate information and I'm getting a /bin/bash error for invalid options although it shows -f as being a shell option.

  7. #7
    Join Date
    2011-08-02
    Location
    http://spikefishsolutions.com
    Posts
    1,652
    Rep Power
    10

    Default Re: Schedule migrate export

    Quote Originally Posted by aweldon View Post
    The script looks great, I went to test it after plugging in the appropriate information and I'm getting a /bin/bash error for invalid options although it shows -f as being a shell option.
    What is it your expecting -f to do? I think think you need any argument on the bash line for your script to work.

  8. #8
    Join Date
    2009-07-21
    Location
    kcmo
    Posts
    47
    Rep Power
    0

    Default Re: Schedule migrate export

    i would recommend using scp with key authentication so you don't need to store a password in plain text. other than that, this is what my script looks like

  9. #9
    Join Date
    2012-08-16
    Posts
    182
    Rep Power
    8

    Default Re: Schedule migrate export

    Quote Originally Posted by jflemingeds View Post
    What is it your expecting -f to do? I think think you need any argument on the bash line for your script to work.
    Honestly I was just trying to test the script. I pulled the -f out and it errors with:
    bash: /usr/local/bin/export.sh: /bin/bash^M: bad interpreter: No such file or directory

  10. #10
    Join Date
    2011-08-02
    Location
    http://spikefishsolutions.com
    Posts
    1,652
    Rep Power
    10

    Default Re: Schedule migrate export

    Quote Originally Posted by aweldon View Post
    Honestly I was just trying to test the script. I pulled the -f out and it errors with:
    bash: /usr/local/bin/export.sh: /bin/bash^M: bad interpreter: No such file or directory
    I think you've somehow got DOS/Windows systle new line ver unix in export.sh


    The way you get the ^M is by doing

    CTRL-V
    CTRL-M

    sed 's/^M//g' export.sh > new.export.sh

    Then try to run new.export.sh

    If that doesn't work let us know.

  11. #11
    Join Date
    2012-08-16
    Posts
    182
    Rep Power
    8

    Default Re: Schedule migrate export

    Thanks, that command did not work so I ran dos2unix export.sh and all seems well now.

    (I used notepad++ and saved as a Unix script without editing the EOL > Unix/OSX format)
    Last edited by aweldon; 2014-06-13 at 12:29.

  12. #12
    Join Date
    2011-08-02
    Location
    http://spikefishsolutions.com
    Posts
    1,652
    Rep Power
    10

    Default Re: Schedule migrate export

    Quote Originally Posted by aweldon View Post
    Thanks, that command did not work so I ran dos2unix export.sh and all seems well now.

    (I used notepad++ and saved as a Unix script without editing the EOL > Unix/OSX format)
    good deal!

  13. #13
    Join Date
    2014-07-31
    Posts
    11
    Rep Power
    0

    Default Re: Schedule migrate export

    Thanks a lot, just used this myself! Took me a little while to fine tune to my requirements as my scripting and linux skills are not all that but I now have a daily upgrade_export going to my FTP server. Just got to work out a way to make it delete any files a week old now :)

    Thanks again - Dave

  14. #14
    Join Date
    2016-09-19
    Posts
    5
    Rep Power
    0

    Default Re: Schedule migrate export

    Is there any way to build some error checking into this? What would happen if a step failed or didn't ftp successful and continues on script and deleted the files?

  15. #15
    Join Date
    2006-04-30
    Location
    Europe, Germany
    Posts
    433
    Rep Power
    14

    Default Re: Schedule migrate export

    Quote Originally Posted by The_Dude View Post
    Is there any way to build some error checking into this? What would happen if a step failed or didn't ftp successful and continues on script and deleted the files?
    This scrip contains some error checking
    https://www.cpug.org/forums/showthre...remote-trigger
    It is an older script and needs some adjustments e.g.
    - replace /opt/CPshrd-R65/tmp/.CPprofile.sh with the path from your version
    - replace "echo | ${EXPT} ${FILE_TGZ}" with "echo y | ${EXPT} ${FILE_TGZ}"

    Since it uses scp it is best to generate an ssh key for the transfer user and place the public part on the target system in the $targetuser/.ssh/authorized_keys file and test if ssh login works without password

  16. #16
    Join Date
    2012-07-10
    Location
    Zurich, Switzerland
    Posts
    257
    Rep Power
    8

    Default Re: Schedule migrate export

    Here 's another one. It works both for SmartCenter and Multi-Domain. It uses SCP as well to copy files. It check the available disk space before starting the backup process and notifies by mail.
    Feel free to adopt to your needs.

    #!/bin/bash
    #
    # Filename: /home/admin/scripts/backup_export.sh
    # ================================================== =============================
    #
    # Shell script to provide regular backup by meamns of exporting the
    # Check Point database of a SmartCenter or Multi Domain Server.
    # The backup type can be specified as either daily, weekly, monthly or quarterly
    # According to the backup type, the number of backup files kept by the purging
    # process varies.
    # If the disk space is not sufficient, no backup will be done
    # It will send an email to an ADMIN group, if the backup has failed
    #
    # Copyright WellComm AG, 2014, Version 1.0
    # -------------------------------------------------------------------------------
    # get correct environment first
    #
    . /etc/bashrc
    #
    # -------------------------------------------------------------------------------
    # Set some variables then
    #
    BACKUPTYPE=""
    FILESTOKEEP=0
    DOMAIN_TYPE=0
    DOMTYPE="sc"
    DOMAIN_NAME="SmartCenter"
    MDSWASTE="CPSmart*.tgz"
    MAILSERVER="192.168.10.1"
    MAILADDRESS="securiy-group@customer.com"
    FACILITY="%BCK-EXP-intro"
    BACKUPTYPES=([0]=daily [1]=weekly [2]=monthly [3]=quarterly)
    FILEVERSIONS=([0]=5 [1]=4 [2]=3 [3]=4)
    #--------------------------------------------------------------------------------
    #
    # Make sure that input parameter is not blank
    #
    if [ "$1" = "" ] ; then
    echo "$FACILITY Input parameter must not be blank, please specify either daily, weekly, monthly or quarterly"
    exit
    fi
    #--------------------------------------------------------------------------------
    # Check which type of backup is selected and assign files to purge
    #
    for idx in 0 1 2 3
    do
    if [ ${BACKUPTYPES[$idx]} = "$1" ] ; then
    BACKUPTYPE=${BACKUPTYPES[$idx]}
    echo "$FACILITY We will do $BACKUPTYPE backup"
    fi
    if [ ${BACKUPTYPES[$idx]} = "$BACKUPTYPE" ] ; then
    FILESTOKEEP=${FILEVERSIONS[$idx]}
    # echo "$FACILITY We will keep $FILESTOKEEP file(s)"
    fi
    done
    # -------------------------------------------------------------------------------
    # Make sure the variables are correct, otherwise quit
    #
    if [ "$BACKUPTYPE" = "" ] ; then
    echo "$FACILITY Illegal input parameter $1 for backup operation specified, exiting"
    exit
    fi
    if [ $FILESTOKEEP = 0 ] ; then
    echo "$FACILITY Illegal parameter $FILESTOKEEP for files to keep in purging operation, exiting"
    exit
    fi
    #
    FACILITY="%BCK-EXP"_"$BACKUPTYPE"
    # -------------------------------------------------------------------------------
    # Check if we are a SmartCenter- or a Multi-Domain-Server and set the
    # start/stop commands accordingly
    #
    if [ "$(command -v mdsstat)" = "" ] ; then
    echo "$FACILITY Identified $(hostname) as a SmartCenter"
    CMDPRFX="cp"
    else
    echo "$FACILITY Identified $(hostname) as a Multi Domain Server"
    CMDPRFX="mds"
    DOMTYPE=$CMDPRFX
    DOMAIN_TYPE=1
    DOMAIN_NAME="Multi Domain"
    fi
    STOPCMD=$CMDPRFX"stop"
    STARTCMD=$CMDPRFX"start"
    # -------------------------------------------------------------------------------
    #
    BACKUPDIR=/var/export/
    #
    BACKUPFILE=${BACKUPDIR}Exported_$(hostname)_${DOMT YPE}_${BACKUPTYPE}_$(date +%Y-%m-%d).tgz
    #
    # set alert level 80% of disk space is default
    ALERT=80
    #
    # -------------------------------------------------------------------------------
    #
    function check_disk_space() {
    while read output;
    do
    #echo $output
    usep=$(echo $output | awk '{ print $2}' | cut -d'%' -f1)
    partition=$(echo $output | awk '{print $3}')
    spaceleft=$(echo $output | awk '{print $1}')
    runstat=0
    if [ $usep -ge $ALERT ] ; then
    echo "$FACILITY Running out of space on partition $partition ($usep% used), only $spaceleft left on server $(hostname), $(date)"
    # mail -s "Alert: Almost out of disk space $usep%" $ADMIN
    runstat=1
    fi
    done
    return $runstat
    }
    #
    # ================================================== =============================
    #
    # start our main task
    #
    #
    echo "$FACILITY Starting $BACKUPTYPE Check Point export backup on server $(hostname), $(date)"
    df -PH $BACKUPDIR | grep -vE "^Filesystem" | awk '{print $4 " " $5 " " $6}' | check_disk_space
    rc=$?
    if [ $rc = 0 ] ; then
    echo "$FACILITY Partition size for $BACKUPDIR is o.k., continuing"
    else
    echo "$FACILITY Partition size for $BACKUPDIR is too small, exiting"
    exit
    fi
    # -------------------------------------------------------------------------------
    #
    # stop the Management Server and perform the backup
    #
    echo "$FACILITY Stopping the $DOMAIN_NAME Server"
    #
    $STOPCMD
    #
    echo "$FACILITY Exporting database files to $BACKUPFILE"
    if [ $DOMAIN_TYPE = 0 ] ; then
    #
    echo "$FACILITY we will now perform: $FWDIR/bin/upgrade_tools/migrate export -n $BACKUPFILE "
    $FWDIR/bin/upgrade_tools/migrate export -n $BACKUPFILE
    else
    MDS_FILE=$(date +%d%b%Y-)*.mdsbk.tgz
    echo "$FACILITY we will now perform: mds_backup -b -l -d /var/export >> /dev/null"
    mds_backup -b -l -d /var/export >> /dev/null
    fi
    #echo "$FACILITY Backup file name is $BACKUPFILE"
    #echo "$FACILITY Wrote $BACKUPTYPE Check Point export backup on server $(hostname), $(date)" > $BACKUPFILE
    rc=$?
    # -------------------------------------------------------------------------------
    # Purge the directory if the backup operation was successful
    #
    if [ $rc = 0 ] ; then
    if [ $DOMAIN_TYPE = 1 ] ; then
    echo "$FACILITY We will now rename $BACKUPDIR$MDS_FILE to $BACKUPFILE"
    mv $BACKUPDIR$MDS_FILE $BACKUPFILE
    FILE=$BACKUPDIR$MDSWASTE
    stat -t $FILE >/dev/null 2>&1
    rc=$?
    if [ $rc = 0 ] ; then
    echo "$FACILITY Cleaning up MDS Backup files $FILE"
    rm $FILE
    fi
    fi
    cd $BACKUPDIR
    echo "$FACILITY Purging files in backup directory $BACKUPDIR"
    files_in_dir=`ls *$BACKUPTYPE* | wc -l`
    files_to_delete=`expr $files_in_dir - $FILESTOKEEP`
    if [ $files_to_delete -gt 0 ]; then
    ls -r *$BACKUPTYPE* | tail -n $files_to_delete | xargs rm
    rc=$?
    if [ $rc -ne 0 ]; then
    echo "$FACILITY An error ocurred deleting the files in $BACKUPDIR"
    else
    echo "$FACILITY $files_to_delete file(s) deleted in $BACKUPDIR."
    fi
    else
    echo "$FACILITY no files to delete while purging the directory $BACKUPDIR!"
    rc=0
    fi
    if [ $rc = 0 ] ; then
    echo "$FACILITY Sucessfully completed $BACKUPTYPE Check Point export backup on server $(hostname), $(date)"
    else
    echo "$FACILITY Failed to purge $BACKUPTYPE Check Point export backups on server $(hostname), $(date)"
    fi
    else
    echo "$FACILITY Failed to write $BACKUPTYPE Check Point export backup on server $(hostname), $(date)"
    echo "$FACILITY Failed to write $BACKUPTYPE Check Point export backup on server $(hostname), $(date)" > $HOME/scripts/backup_state.txt
    echo "Return status is $rc"
    $FWDIR/bin/sendmail -t $MAILSERVER -s 'Check Point Backup Failure' -f sendmail@$HOSTNAME $MAILADDRESS < $HOME/scripts/backup_state.txt
    fi
    #
    # -------------------------------------------------------------------------------
    # restart the mgmt server
    #
    echo "$FACILITY Re-starting the $DOMAIN_NAME Server"
    $STARTCMD
    #
    # well, that's it, we are done
    #
    # -------------------------------------------------------------------------------
    Last edited by slowfood27; 2016-09-20 at 01:32. Reason: more dteails

  17. #17
    Join Date
    2012-07-10
    Location
    Zurich, Switzerland
    Posts
    257
    Rep Power
    8

    Default Re: Schedule migrate export

    Here 's another one. It works both for SmartCenter and Multi-Domain. It check the available disk space before starting the backup process and notifies by mail.
    Feel free to adopt to your needs. If you need scp copy with keys as a script, drop me a PM

    #!/bin/bash
    #
    # Filename: /home/admin/scripts/backup_export.sh
    # ================================================== =============================
    #
    # Shell script to provide regular backup by meamns of exporting the
    # Check Point database of a SmartCenter or Multi Domain Server.
    # The backup type can be specified as either daily, weekly, monthly or quarterly
    # According to the backup type, the number of backup files kept by the purging
    # process varies.
    # If the disk space is not sufficient, no backup will be done
    # It will send an email to an ADMIN group, if the backup has failed
    #
    # Copyright WellComm AG, 2014, Version 1.0
    # -------------------------------------------------------------------------------
    # get correct environment first
    #
    . /etc/bashrc
    #
    # -------------------------------------------------------------------------------
    # Set some variables then
    #
    BACKUPTYPE=""
    FILESTOKEEP=0
    DOMAIN_TYPE=0
    DOMTYPE="sc"
    DOMAIN_NAME="SmartCenter"
    MDSWASTE="CPSmart*.tgz"
    MAILSERVER="192.168.10.1"
    MAILADDRESS="securiy-group@customer.com"
    FACILITY="%BCK-EXP-intro"
    BACKUPTYPES=([0]=daily [1]=weekly [2]=monthly [3]=quarterly)
    FILEVERSIONS=([0]=5 [1]=4 [2]=3 [3]=4)
    #--------------------------------------------------------------------------------
    #
    # Make sure that input parameter is not blank
    #
    if [ "$1" = "" ] ; then
    echo "$FACILITY Input parameter must not be blank, please specify either daily, weekly, monthly or quarterly"
    exit
    fi
    #--------------------------------------------------------------------------------
    # Check which type of backup is selected and assign files to purge
    #
    for idx in 0 1 2 3
    do
    if [ ${BACKUPTYPES[$idx]} = "$1" ] ; then
    BACKUPTYPE=${BACKUPTYPES[$idx]}
    echo "$FACILITY We will do $BACKUPTYPE backup"
    fi
    if [ ${BACKUPTYPES[$idx]} = "$BACKUPTYPE" ] ; then
    FILESTOKEEP=${FILEVERSIONS[$idx]}
    # echo "$FACILITY We will keep $FILESTOKEEP file(s)"
    fi
    done
    # -------------------------------------------------------------------------------
    # Make sure the variables are correct, otherwise quit
    #
    if [ "$BACKUPTYPE" = "" ] ; then
    echo "$FACILITY Illegal input parameter $1 for backup operation specified, exiting"
    exit
    fi
    if [ $FILESTOKEEP = 0 ] ; then
    echo "$FACILITY Illegal parameter $FILESTOKEEP for files to keep in purging operation, exiting"
    exit
    fi
    #
    FACILITY="%BCK-EXP"_"$BACKUPTYPE"
    # -------------------------------------------------------------------------------
    # Check if we are a SmartCenter- or a Multi-Domain-Server and set the
    # start/stop commands accordingly
    #
    if [ "$(command -v mdsstat)" = "" ] ; then
    echo "$FACILITY Identified $(hostname) as a SmartCenter"
    CMDPRFX="cp"
    else
    echo "$FACILITY Identified $(hostname) as a Multi Domain Server"
    CMDPRFX="mds"
    DOMTYPE=$CMDPRFX
    DOMAIN_TYPE=1
    DOMAIN_NAME="Multi Domain"
    fi
    STOPCMD=$CMDPRFX"stop"
    STARTCMD=$CMDPRFX"start"
    # -------------------------------------------------------------------------------
    #
    BACKUPDIR=/var/export/
    #
    BACKUPFILE=${BACKUPDIR}Exported_$(hostname)_${DOMT YPE}_${BACKUPTYPE}_$(date +%Y-%m-%d).tgz
    #
    # set alert level 80% of disk space is default
    ALERT=80
    #
    # -------------------------------------------------------------------------------
    #
    function check_disk_space() {
    while read output;
    do
    #echo $output
    usep=$(echo $output | awk '{ print $2}' | cut -d'%' -f1)
    partition=$(echo $output | awk '{print $3}')
    spaceleft=$(echo $output | awk '{print $1}')
    runstat=0
    if [ $usep -ge $ALERT ] ; then
    echo "$FACILITY Running out of space on partition $partition ($usep% used), only $spaceleft left on server $(hostname), $(date)"
    # mail -s "Alert: Almost out of disk space $usep%" $ADMIN
    runstat=1
    fi
    done
    return $runstat
    }
    #
    # ================================================== =============================
    #
    # start our main task
    #
    #
    echo "$FACILITY Starting $BACKUPTYPE Check Point export backup on server $(hostname), $(date)"
    df -PH $BACKUPDIR | grep -vE "^Filesystem" | awk '{print $4 " " $5 " " $6}' | check_disk_space
    rc=$?
    if [ $rc = 0 ] ; then
    echo "$FACILITY Partition size for $BACKUPDIR is o.k., continuing"
    else
    echo "$FACILITY Partition size for $BACKUPDIR is too small, exiting"
    exit
    fi
    # -------------------------------------------------------------------------------
    #
    # stop the Management Server and perform the backup
    #
    echo "$FACILITY Stopping the $DOMAIN_NAME Server"
    #
    $STOPCMD
    #
    echo "$FACILITY Exporting database files to $BACKUPFILE"
    if [ $DOMAIN_TYPE = 0 ] ; then
    #
    echo "$FACILITY we will now perform: $FWDIR/bin/upgrade_tools/migrate export -n $BACKUPFILE "
    $FWDIR/bin/upgrade_tools/migrate export -n $BACKUPFILE
    else
    MDS_FILE=$(date +%d%b%Y-)*.mdsbk.tgz
    echo "$FACILITY we will now perform: mds_backup -b -l -d /var/export >> /dev/null"
    mds_backup -b -l -d /var/export >> /dev/null
    fi
    #echo "$FACILITY Backup file name is $BACKUPFILE"
    #echo "$FACILITY Wrote $BACKUPTYPE Check Point export backup on server $(hostname), $(date)" > $BACKUPFILE
    rc=$?
    # -------------------------------------------------------------------------------
    # Purge the directory if the backup operation was successful
    #
    if [ $rc = 0 ] ; then
    if [ $DOMAIN_TYPE = 1 ] ; then
    echo "$FACILITY We will now rename $BACKUPDIR$MDS_FILE to $BACKUPFILE"
    mv $BACKUPDIR$MDS_FILE $BACKUPFILE
    FILE=$BACKUPDIR$MDSWASTE
    stat -t $FILE >/dev/null 2>&1
    rc=$?
    if [ $rc = 0 ] ; then
    echo "$FACILITY Cleaning up MDS Backup files $FILE"
    rm $FILE
    fi
    fi
    cd $BACKUPDIR
    echo "$FACILITY Purging files in backup directory $BACKUPDIR"
    files_in_dir=`ls *$BACKUPTYPE* | wc -l`
    files_to_delete=`expr $files_in_dir - $FILESTOKEEP`
    if [ $files_to_delete -gt 0 ]; then
    ls -r *$BACKUPTYPE* | tail -n $files_to_delete | xargs rm
    rc=$?
    if [ $rc -ne 0 ]; then
    echo "$FACILITY An error ocurred deleting the files in $BACKUPDIR"
    else
    echo "$FACILITY $files_to_delete file(s) deleted in $BACKUPDIR."
    fi
    else
    echo "$FACILITY no files to delete while purging the directory $BACKUPDIR!"
    rc=0
    fi
    if [ $rc = 0 ] ; then
    echo "$FACILITY Sucessfully completed $BACKUPTYPE Check Point export backup on server $(hostname), $(date)"
    else
    echo "$FACILITY Failed to purge $BACKUPTYPE Check Point export backups on server $(hostname), $(date)"
    fi
    else
    echo "$FACILITY Failed to write $BACKUPTYPE Check Point export backup on server $(hostname), $(date)"
    echo "$FACILITY Failed to write $BACKUPTYPE Check Point export backup on server $(hostname), $(date)" > $HOME/scripts/backup_state.txt
    echo "Return status is $rc"
    $FWDIR/bin/sendmail -t $MAILSERVER -s 'Check Point Backup Failure' -f sendmail@$HOSTNAME $MAILADDRESS < $HOME/scripts/backup_state.txt
    fi
    #
    # -------------------------------------------------------------------------------
    # restart the mgmt server
    #
    echo "$FACILITY Re-starting the $DOMAIN_NAME Server"
    $STARTCMD
    #
    # well, that's it, we are done
    #
    # -------------------------------------------------------------------------------

Similar Threads

  1. How to Schedule Snapshot on Splat?
    By Jinshu in forum Check Point Backup Procedures
    Replies: 4
    Last Post: 2014-03-12, 00:06
  2. R75.20 SmartCenter Smart-1 5 Automated Migrate Export Script Issue
    By netstorm in forum Check Point Smart-1 Security Management Appliances
    Replies: 2
    Last Post: 2012-01-24, 12:31
  3. Migrate Export R75.10 Question
    By gbullock in forum Check Point Backup Procedures
    Replies: 3
    Last Post: 2011-08-23, 03:20
  4. Schedule Backup Fails
    By oayyildiz in forum Check Point Backup Procedures
    Replies: 3
    Last Post: 2009-09-08, 14:51
  5. schedule rule installation
    By jmosorio in forum SmartDashboard
    Replies: 2
    Last Post: 2008-03-12, 05:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •