cancel
Showing results for 
Search instead for 
Did you mean: 
Post a Question

Script to run migrate export backup

hi,

How can we schedule the migrate export backup everyday and push it to another server with the backup file name with date. Tried with job scheduler but there we find some limitation.

Regards,

Sagar Manandhar

9 Replies
Highlighted
Maarten_Sjouw
Platinum

Re: Script to run migrate export backup

please check this question and it's responses.

Although if you want to move the file to another linux machine, I would use SCP instead of FTP.

Using a SSH Key instead of password:


echo '--------------------------------------------' >>$LOG
timestamp 'Send system logs to SCP server ... ' >>$LOG
echo '--------------------------------------------' >>$LOG
timestamp 'Starting SCP session ...' >>$LOG

if [ X${BACKUP_REMOTE} != X ]; then
if [ X${BACKUP_KEY} == X ]; then
_key="${HOME}/.ssh/id_dsa"
else
_key=$BACKUP_KEY
fi
scp -Bpqvi ${_key} $MDS_BCKDIR/* $BACKUP_REMOTE_USER@$BACKUP_REMOTE:$BACKUP_REMOTE_PATH 2>&1 | grep -v debug >>$LOG
fi

Regards, Maarten
Admin
Admin

Re: Script to run migrate export backup

What script did you write to try and do this?

Perhaps we can improve it?

Re: Script to run migrate export backup

There is the backup script I wrote. Feel free to modify it for your needs and I if you improve it please share that with us:

#!/bin/bash

###########################################################################
BACKUP_FILE=backup_CPSMS_`date +%d-%m-%y_%H%M`.tgz

BACKUP_PATH=/var/CPbackup/backups

BACKUP_COMMAND="/opt/CPsuite-R80/fw1/bin/upgrade_tools/migrate export -n"

BACKUP_SERVER='192.168.x.x'

BACKUP_USER='ftp_user'

BACKUP_PASS='ftp_pass'

###########################################################################

source /etc/profile.d/CP.sh

echo `date +%d-%m-%yT%H%M` INFO: Backup script started

cd $BACKUP_PATH

# Run backup command
echo `date +%d-%m-%yT%H%M` "INFO: Running $BACKUP_COMMAND $BACKUP_FILE"
$BACKUP_COMMAND $BACKUP_FILE
if [ $? -ne 0 ]; then
echo `date +%d-%m-%yT%H%M` "FATAL: Backup command did not complete successfully"

exit 1
else
echo `date +%d-%m-%yT%H%M` "INFO: Backup command completed successfully"
fi

# Test backup file integrity
echo `date +%d-%m-%yT%H%M` "INFO: Testing archive integrity..."
/bin/tar -tzf $BACKUP_FILE > /dev/null
if [ $? -ne 0 ]; then
echo `date +%d-%m-%yT%H%M` "FATAL: Archive integrity test failed. Backup file is corrupt."

exit 1
else
echo `date +%d-%m-%yT%H%M` "INFO: Archive integrity test succeeded. Backup file is good."
echo `date +%d-%m-%yT%H%M` "INFO: Creating checksum file $BACKUP_FILE.MD5SUM"
/usr/bin/md5sum $BACKUP_FILE > $BACKUP_FILE.MD5SUM
echo `date +%d-%m-%yT%H%M` "INFO: Uploading archive to FTP server..."

/usr/bin/ftp -n $BACKUP_SERVER <<END_SCRIPT
quote USER $BACKUP_USER
quote PASS $BACKUP_PASS
cd CPSMS
put $BACKUP_FILE.MD5SUM
binary
put $BACKUP_FILE
quit
END_SCRIPT

if [ $? -ne 0 ]; then

echo `date +%d-%m-%yT%H%M` "ERROR: FTP upload failed."

else

echo `date +%d-%m-%yT%H%M` "INFO: FTP upload completed."

fi

fi

echo `date +%d-%m-%yT%H%M` INFO: Backup script completed

Re: Script to run migrate export backup

I see error when I used contrab but manual run working fine anyone have the same error.

This utility requires the Check Point Security Management Server.

26-12-18T1041 FATAL: Backup command did not complete successfully

Re: Script to run migrate export backup

Sorry mate, script was missing importing CP environment. I fixed it so try now. It should work fine from crontab.

ITD_TS
Ivory

Re: Script to run migrate export backup

Hristo,

It is not working with R80.20 M2.

0 Kudos

Re: Script to run migrate export backup

Yeah, it is possible. What does it output when you run it ?

0 Kudos
ITD_TS
Ivory

Re: Script to run migrate export backup

Eror:

T2359 FATAL: Backup command did not complete successfully

0 Kudos

Re: Script to run migrate export backup

Please run following command:

expert# bash -x /path/to/backup_export.sh

Replace any possible confidential info in the output and paste it here.

0 Kudos